home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / editor / par.zip / MANUAL.DOC < prev    next >
Text File  |  1997-06-27  |  416KB  |  11,055 lines

  1.     ===========================================================================
  2.     ===========================================================================
  3.     ============================                   ============================
  4.     ============================                   ============================
  5.     ============================   PARSE-O-MATIC   ============================
  6.     ============================                   ============================
  7.     ============================                   ============================
  8.     ===========================================================================
  9.     ===========================================================================
  10.  
  11.  
  12.               Copyright (C) 1986, 1997 by Pinnacle Software (Montreal)
  13.  
  14.  
  15.     +-------------------------- WIDE APPLICABILITY ---------------------------+
  16.     |                                                                         |
  17.     |                                                                         |
  18.     |          Runs under MS-DOS, Windows (3.1 or 95), Novell & OS/2          |
  19.     |                                                                         |
  20.     |          Can be invoked by other DOS, Windows or OS/2 programs          |
  21.     |          such as FoxPro, Pascal, Visual Basic, C++, Delphi and          |
  22.     |          so on, with success verification (return code or log)          |
  23.     |                                                                         |
  24.     |          Can be run under DOS emulators (e.g. Macintosh, Unix)          |
  25.     |          for convenient cross-platform conversion.                      |
  26.     |                                                                         |
  27.     |                                                                         |
  28.     +------- HERE ARE A FEW OF THE THINGS PARSE-O-MATIC CAN DO FOR YOU -------+
  29.     |                                                                         |
  30.     |                                                                         |
  31.     |      Importing             Exporting             Automated Editing      |
  32.     |      Text Extraction       Data Conversion       Table Lookup           |
  33.     |      Retabulation          Info Weeding          Selective Copying      |
  34.     |      Binary-File to Text   Report Reformatting   Wide-Text Folding      |
  35.     |      Auto-Batch Creation   Comm-log Trimming     Tab Replacement        |
  36.     |      Character Filtering   Column Switching      DBF Interpretation     |
  37.     |      De-uppercasing        Name Properization    And much more!         |
  38.     |                                                                         |
  39.     |                                                                         |
  40.     +---- INPUT AND OUTPUT METHODS CURRENTLY SUPPORTED BY PARSE-O-MATIC ------+
  41.     |                                                                         |
  42.     |                                                                         |
  43.     |   Input:  Text (any format), Binary, DBF (DBase), Fixed-Record-Length,  |
  44.     |           Variable-Record-Length, EBCDIC                                |
  45.     |                                                                         |
  46.     |  Output:  Text (e.g. flat, comma-delimited, paginated, hex), Binary,    |
  47.     |           Fixed-Record-Length, Variable-Record-Length, EBCDIC,          |
  48.     |           Generic output devices (e.g. COM1: or LPT2:)                  |
  49.     |                                                                         |
  50.     |                                                                         |
  51.     +-------------------------------------------------------------------------+
  52.  
  53.  
  54.  
  55.  
  56.  
  57.     +------------ UNSOLICITED TESTIMONIALS (USED WITH PERMISSION) ------------+
  58.     |                                                                         |
  59.     |                                                                         |
  60.     |   "Parse-O-Matic is absolutely great.  I use it when I collect data     |
  61.     |   from the McDonald's restaurants in Switzerland.  POM has paid for     |
  62.     |   itself so many times ..." -- Chris Friedli                            |
  63.     |                                                                         |
  64.     |                                                                         |
  65.     +-------------------------------------------------------------------------+
  66.     |                                                                         |
  67.     |                                                                         |
  68.     |   "Parse-O-Matic is a wonderful time saver .... Each report that I      |
  69.     |   can convert from our ... accounting system saves our company about    |
  70.     |   500 man hours per year." -- R. Brooker                                |
  71.     |                                                                         |
  72.     |                                                                         |
  73.     +-------------------------------------------------------------------------+
  74.     |                                                                         |
  75.     |                                                                         |
  76.     |   "In 30 years of working with computers, this is by far the easiest    |
  77.     |   way I have found to extract data from files.  I was very surprised    |
  78.     |   that the program just took a few seconds to chew its way through      |
  79.     |   1MB of data.  You ought to mention it's FAST." -- Koenraad Rutgers    |
  80.     |                                                                         |
  81.     |                                                                         |
  82.     +-------------------------------------------------------------------------+
  83.     |                                                                         |
  84.     |                                                                         |
  85.     |   "Parse-O-Matic is THE greatest parsing package .... I wrote my own    |
  86.     |   software for parsing ... then I was introduced to POM and have been   |
  87.     |   using it ever since.  Good job!" -- Jeff Tallent, Vestax Securities   |
  88.     |                                                                         |
  89.     |                                                                         |
  90.     +-------------------------------------------------------------------------+
  91.  
  92.  
  93.  
  94.  
  95.     +---------------------- PARSE-O-MATIC IS VERSATILE -----------------------+
  96.     |                                                                         |
  97.     |                                                                         |
  98.     |                                                                         |
  99.     |    This manual was formatted by Parse-O-Matic, from plain text files.   |
  100.     |        The table of contents was also generated by Parse-O-Matic.       |
  101.     |                                                                         |
  102.     |                                                                         |
  103.     |                                                                         |
  104.     +-------------------------------------------------------------------------+
  105.  
  106.  
  107.  
  108.  
  109.     +------------------------ WHO USES PARSE-O-MATIC? ------------------------+
  110.     |                                                                         |
  111.     |                                                                         |
  112.     |              Some of our distinguished customers include:               |
  113.     |                                                                         |
  114.     |                                                                         |
  115.     |  Bankers Trust           HBO (Home Box Office)   Philip Morris          |
  116.     |                                                                         |
  117.     |  Berliner Volksbank      Harris Semiconductor    Pitney Bowes           |
  118.     |                                                                         |
  119.     |  Boeing                  Home Box Office         Prentice Hall          |
  120.     |                                                                         |
  121.     |  Bridgestone             Hughes                  Procter and Gamble     |
  122.     |                                                                         |
  123.     |  CIBA Vision             Ingram                  Rank Xerox             |
  124.     |                                                                         |
  125.     |  Calcomp Canada          Kodak                   Royal Bank             |
  126.     |                                                                         |
  127.     |  Champion Int'l          Lipton Tea              Royal Caribbean        |
  128.     |                                                                         |
  129.     |  CompUSA                 May Department Stores   SmithKline Beacham     |
  130.     |                                                                         |
  131.     |  Degussa                 McCain Foods            Southwest Bancorp      |
  132.     |                                                                         |
  133.     |  Dresdner Bank           McDonald's              Sun Life               |
  134.     |                                                                         |
  135.     |  Eaton                   Monsanto France         Sundstrand Aerospace   |
  136.     |                                                                         |
  137.     |  Eddy                    NEC                     Target                 |
  138.     |                                                                         |
  139.     |  European American Bank  Nestle                  Visa International     |
  140.     |                                                                         |
  141.     |  First Bank System       Nike                    Yale University Press  |
  142.     |                                                                         |
  143.     |  First Federal           Novell                  Ziff-Davis             |
  144.     |                                                                         |
  145.     |  Georgia Gulf            Pacific Gas & Electric  and so on ...          |
  146.     |                                                                         |
  147.     |                                                                         |
  148.     +-------------------------------------------------------------------------+
  149.  
  150.     
  151.     +-------------------------------------------------------------------------+
  152.     |                                                                         |
  153.     |                                                                         |
  154.     |       The above list includes our best known customers, but omits       |
  155.     |       city, state or provincial government offices and hospitals.       |
  156.     |                                                                         |
  157.     |                                                                         |
  158.     +-------------------------------------------------------------------------+
  159.  
  160.  
  161.     ============================================================================
  162.                                  TABLE OF CONTENTS
  163.     ============================================================================
  164.  
  165.     INTRODUCTION  1
  166.        What is Parse-O-Matic?  1
  167.        Parse-O-Matic Versus Automatic Converters  1
  168.        Why You Need Parse-O-Matic -- An Example  2
  169.        Parse-O-Matic to the Rescue!  2
  170.        How It Works  3
  171.        How To Contact Us  3
  172.  
  173.     FUNDAMENTALS  4
  174.        The Parse-O-Matic Command  4
  175.        The POM File  4
  176.        Padding for Clarity  5
  177.        A Simple Example  6
  178.  
  179.     QUICK REFERENCE  7
  180.        Command Descriptions  7
  181.           Basic Commands  7
  182.           Output Commands  7
  183.           Input Commands  7
  184.           Input Filters  7
  185.           Flow Control Commands  8
  186.           Variable Modifiers  8
  187.           Free-Form Commands  8
  188.           Positional Commands  8
  189.           Date Commands  8
  190.           Calculation Commands  9
  191.           Input Preprocessors  9
  192.           Lookup Commands  9
  193.           Data Converters  9
  194.           Miscellaneous Commands  9
  195.        Command Formats  10
  196.  
  197.     BASIC COMMANDS  12
  198.        The SET Command  12
  199.        The IF Command  13
  200.  
  201.     OUTPUT COMMANDS  14
  202.        The KEEP Command  14
  203.        The OFILE Command  15
  204.           Basic Usage  15
  205.           Closing the Output File  16
  206.           Strong Deduction  16
  207.           Weak Deduction  17
  208.           Appended Deductions  18
  209.        The OUT and OUTEND Commands  18
  210.           Generating a Blank Line  19
  211.           Missing Output  19
  212.        The OUTHDG Command  20
  213.        The OUTPAGE Command  21
  214.        The PAGELEN Command  22
  215.  
  216.     INPUT COMMANDS  23
  217.        The GET Command  23
  218.           Variable Length Records  24
  219.           Delimiter-Terminated Data  26
  220.           Handling Long Delimiter-Terminated Data  27
  221.           Using GET with Text Files  27
  222.           End-of-File Considerations  28
  223.        The GETTEXT Command  29
  224.        The READNEXT Command  30
  225.           End of File Conditions  30
  226.           Optional Comparisons  30
  227.           Ignoring Null Lines  31
  228.           Saving the Previous Line  31
  229.        The REWIND Command  32
  230.           Why REWIND is Necessary  32
  231.           Using REWIND  32
  232.           Example  33
  233.  
  234.     INPUT FILTERS  34
  235.        The MINLEN Command  34
  236.        The IGNORE Command  35
  237.        The ACCEPT Command  35
  238.           Clustered Accepts  36
  239.  
  240.     FLOW CONTROL COMMANDS  37
  241.        The BEGIN Command  37
  242.        The CALL Command  39
  243.           Variable CALLs  39
  244.           Making Your Technique Obvious  39
  245.           Avoiding Unknown Code Sections  40
  246.        The CODE Command  41
  247.           Performance Considerations  42
  248.           Nested Subroutine Calls  42
  249.           Variable Code Sections  42
  250.           A Note to Experienced Programmers  43
  251.        The ELSE Command  43
  252.        The END Command  44
  253.        The AGAIN Command  45
  254.           Using AGAIN for Variable-Length Data  46
  255.           Pointless Command Combinations  47
  256.           Examples  47
  257.        The DONE Command  48
  258.        The NEXTFILE Command  50
  259.        The HALT Command  51
  260.        The PROLOGUE Command  52
  261.        The EPILOGUE Command  53
  262.  
  263.     VARIABLE MODIFIERS  54
  264.        The TRIM Command  54
  265.        The PAD Command  55
  266.        The CHANGE Command  56
  267.        The CVTCASE Command  56
  268.           Control Settings  57
  269.        The PROPER Command  58
  270.        The INSERT Command  60
  271.        The APPEND Command  61
  272.        The OVERLAY Command  62
  273.           Simple Arrays  63
  274.        The MAPFILE Command  64
  275.           What is a Map File?  64
  276.           Sample Map Files  64
  277.           Map File Format  65
  278.           Search Order  65
  279.           Case Matching  66
  280.           Reverse Mapping  66
  281.           Irreversible Mapping  67
  282.           Memory Limitations  68
  283.           An Example of Remapping  68
  284.        The REMAP Command  69
  285.           REMAP Versus CHANGE  69
  286.           Using REMAP  70
  287.  
  288.     FREE-FORM COMMANDS  71
  289.        What are Free-Form Commands?  71
  290.        The PARSE Command  72
  291.           Decapsulators  72
  292.           Sample Application  73
  293.           The Occurence Number  73
  294.           Finding the Last Occurence  74
  295.           Unsuccessful Searches  74
  296.           The Control Setting  75
  297.           The Plain Decapsulator  75
  298.           The Null Decapsulator  75
  299.           Null Decapsulators Versus Exclusion  76
  300.           Overlapping Decapsulators  76
  301.           Parsing Empty Fields  77
  302.           Additional Examples  77
  303.        The PEEL Command  78
  304.           The Control Setting  79
  305.           Parsing Empty Fields  79
  306.           The Left-Peeling Technique  80
  307.           The Leftover Technique  80
  308.  
  309.     POSITIONAL COMMANDS  82
  310.        General Discussion  82
  311.           What are Positional Commands?  82
  312.           Why Use Positional Commands?  82
  313.           A Cautionary Note  83
  314.        The SETLEN Command  84
  315.        The DELETE Command  85
  316.        The COPY Command  86
  317.        The EXTRACT Command  87
  318.        The FINDPOSN Command  88
  319.           The Plain String Find  88
  320.           Using a Single Decapsulator  89
  321.           The Encapsulated String Find  89
  322.           Control Settings  91
  323.           Insoluble Searches  92
  324.           Null Decapsulators  92
  325.           Finding The Last Word  93
  326.           Who Needs This?  93
  327.        The SCANPOSN Command  93
  328.           The Scanlist  94
  329.           Accomodating Variation  95
  330.           Handling Prefixes and Suffixes  95
  331.           Controlling the Search  96
  332.           Leftmost, Rightmost, Find-Any  96
  333.           The Best Match Principle  97
  334.  
  335.     DATE COMMANDS  99
  336.        General Discussion  99
  337.           The POMDATE.CFG File  99
  338.           Date Formats  99
  339.        The TODAY Command  101
  340.        The DATE Command  102
  341.        The MONTHNUM Command  103
  342.        The ZERODATE Command  104
  343.  
  344.     CALCULATION COMMANDS  105
  345.        The CALC Command  105
  346.        The CALCREAL Command  106
  347.        The ROUNDING Command  108
  348.        The CALCBITS Command  109
  349.  
  350.     INPUT PREPROCESSORS  111
  351.        The SPLIT Command  111
  352.           Indicating Actual Input Length  112
  353.           Non-Contiguous Splits  112
  354.        The CHOP Command  112
  355.           Manual Reading  113
  356.  
  357.     LOOKUP COMMANDS  114
  358.        The LOOKUP Command  114
  359.           Search Method  115
  360.           Limitations  115
  361.           Null Lines and Comments  116
  362.           Multiple Columns  116
  363.           LOOKUP Versus REMAP  117
  364.        The LOOKFILE Command  117
  365.        The LOOKCOLS Command  118
  366.        The LOOKSPEC Command  119
  367.  
  368.     DATA CONVERTERS  120
  369.        The MAKEDATA Command  120
  370.           Creating Binary Data  120
  371.           Converting Dates  121
  372.           Practical Considerations  122
  373.        The MAKETEXT Command  122
  374.           Converting Binary Data  123
  375.           Converting Dates  123
  376.           Practical Considerations  123
  377.  
  378.     MISCELLANEOUS COMMANDS  124
  379.        The ERASE Command  124
  380.        The FILESIZE Command  125
  381.        The GETENV Command  125
  382.           Disappearing Environment Variables  126
  383.           Examples  126
  384.        The LOG Command  127
  385.        The MSGWAIT Command  128
  386.           Standard Behaviour  128
  387.           Setting a Time-Out Delay  129
  388.           Color Cues  129
  389.           Key Stacking  129
  390.           Exceptions  129
  391.           A Word of Caution  130
  392.        The PAUSE Command  130
  393.        The RANDOM Command  131
  394.        The SHOWNOTE Command  132
  395.           Other Notes  133
  396.           Slowing Down  133
  397.        The SOUND Command  134
  398.           The LISTEN Utility  134
  399.           Changing the Error Message Sound  135
  400.        The TRACE Command  135
  401.  
  402.     TERMS  136
  403.        Values  136
  404.        Variables  136
  405.        Predefined Values  137
  406.           $FLINE  137
  407.           $FLUPC  137
  408.           $SPLIT  138
  409.           $LINECOUNTER  138
  410.        Running Out of Variables, Literals or Lines  140
  411.        Delimiters  140
  412.        Illegal Characters  140
  413.        Using Comparators  141
  414.           Literal Comparisons and Sort Order  142
  415.           Numeric Comparisons  142
  416.           Upgrading from Earlier Versions  143
  417.        Predefined Data Types  144
  418.           Interpreting Data Formats in a File  145
  419.  
  420.     DEDUCED VARIABLES  146
  421.        Deduced Variables  146
  422.           Definition  146
  423.           The Look-Up Process  147
  424.           Restrictions  147
  425.           Usage Guidelines  148
  426.        Array Variables  149
  427.           Multidimensional Arrays  150
  428.        Eponymous Variables  151
  429.           Drawbacks and Advantages  152
  430.  
  431.     VALUE TECHNIQUES  153
  432.        Uninitialized and Persistent Variables  153
  433.           Example  153
  434.        Inline Incrementing and Decrementing  154
  435.        Line Counters  155
  436.        The SHOWNUM Utility  155
  437.           Quick Reference Screen  155
  438.           Converting a Number  156
  439.           Converting a Character  156
  440.           Windows Considerations  157
  441.  
  442.     PROGRAMMING TECHNIQUES  158
  443.        Tracing  158
  444.        Logging  159
  445.  
  446.     COMMAND-LINE TECHNIQUES  160
  447.        Quiet Mode  160
  448.        User-Specified Command-Line Parameters  160
  449.        Summary  163
  450.  
  451.     FILE HANDLING  164
  452.        How Parse-O-Matic Searches for a File  164
  453.        How Parse-O-Matic Opens an Output File  165
  454.        Appending to an Output File  167
  455.        Sending Output to a Device  168
  456.           COM Ports  168
  457.        DbF Files  169
  458.        POM and Wildcards  170
  459.  
  460.     OPERATIONAL TECHNIQUES  172
  461.        Parse-O-Matic Job (POJ) Files  172
  462.           Simple Usage  172
  463.           Commenting a Job File  172
  464.           Prompting for File Names  173
  465.           Suggesting File Names  174
  466.           Optional Parameters  174
  467.           Examples  175
  468.        Encrypted (Scrambled) POM Files  175
  469.           The SCRAMBLE Utility  175
  470.           Why Scramble a POM File?  176
  471.           Support Considerations  176
  472.        Batch Files  177
  473.        Unattended Operation  181
  474.        Examples  183
  475.  
  476.     OPERATIONAL CONSIDERATIONS  184
  477.        Running Parse-O-Matic on 8088 and 8086 Machines  184
  478.        Running Parse-O-Matic from Another Program  184
  479.        Solving Memory Problems  185
  480.  
  481.     RUNNING UNDER WINDOWS  186
  482.        Compatibility  186
  483.        Setting Up for Windows 95  186
  484.           Setting Up an Association for the POM File  187
  485.           Setting Up an Association for a POJ (Job) File  188
  486.           Setting Up an Association for the BAT File (Optional)  189
  487.        Installing the ShowNum Utility  190
  488.        Long File Names in Win95  190
  489.  
  490.     LICENSING  191
  491.        Parse-O-Matic Licenses  191
  492.        The SEE Utility  192
  493.  
  494.  
  495.     
  496.     ============================================================================
  497.                                     INTRODUCTION
  498.     ============================================================================
  499.     
  500.                                ----------------------
  501.                                What is Parse-O-Matic?
  502.                                ----------------------
  503.     
  504.     Parse-O-Matic is a programmable file-parser.  Simple enough for even a non-
  505.     programmer to master, it can help out in countless ways.  If you have a
  506.     file you want to edit, manipulate, or change around, Parse-O-Matic may be
  507.     just the tool you need.  Parse-O-Matic can also speed up or automate long
  508.     or repetitive editing tasks.
  509.     
  510.                      -----------------------------------------
  511.                      Parse-O-Matic Versus Automatic Converters
  512.                      -----------------------------------------
  513.     
  514.     Parse-O-Matic is not an "automatic file converter".  It will not, for
  515.     example, convert WordPerfect files to MS-Word format, or convert Lotus
  516.     1-2-3 Spreadsheets DIRECTLY to Excel files -- although it can read reports
  517.     from one program and convert them to another format (e.g. comma-delimited),
  518.     which can be imported by the other program.
  519.     
  520.     One advantage of this method (as opposed to automatic file conversion) is
  521.     that you can create an "intelligent" importing procedure, which can make
  522.     decisions and modify data.  You could, for example, eliminate certain types
  523.     of records, tidy up names, convert case, unify fields, make calculations,
  524.     and so on.
  525.     
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.                                                                               1
  550.                       ----------------------------------------
  551.                       Why You Need Parse-O-Matic -- An Example
  552.                       ----------------------------------------
  553.     
  554.     There are plenty of programs out there that have valuable data locked away
  555.     inside them.  How do you get that data OUT of one program and into another
  556.     one?
  557.     
  558.     Some programs provide a feature which "exports" a file into some kind of
  559.     generic format.  Perhaps the most popular of these formats is known as a
  560.     "comma-delimited file", which is a text file in which each data field is
  561.     separated by a comma.  Character strings -- which might themselves contain
  562.     commas -- are surrounded by double quotes.  So a few lines from a
  563.     comma-delimited file might look something like this (an export from a
  564.     hypothetical database of people who owe your company money):
  565.     
  566.     "JONES","FRED","1234 GREEN AVENUE", "KANSAS CITY", "MO",293.64
  567.     "SMITH","JOHN","2343 OAK STREET","NEW YORK","NY",22.50
  568.     "WILLIAMS","JOSEPH","23 GARDEN CRESCENT","TORONTO","ON",16.99
  569.     
  570.     Unfortunately, not all programs export or import data in this format.
  571.     Even more frustrating is a program that exports data in a format that is
  572.     ALMOST what you need!
  573.     
  574.     If that's the case, you might decide to spend a few hours in a text editor,
  575.     modifying the export file so that the other program can understand it.  Or
  576.     you might write a program to do the editing for you.  Both solutions are
  577.     time-consuming.
  578.     
  579.     An even more challenging problem arises when a program which has no export
  580.     capability does have the ability to "print" reports to a file.  You can
  581.     write a program to read these files and convert them to something you can
  582.     use, but this can be a LOT of work!
  583.     
  584.                             ----------------------------
  585.                             Parse-O-Matic to the Rescue!
  586.                             ----------------------------
  587.     
  588.     Parse-O-Matic is a utility that reads a file, interprets the data, and
  589.     outputs the result to another file.  It can help you "boil down" data to
  590.     its essential information.  You can also use it to convert NEARLY
  591.     compatible import files, or generate printable reports.
  592.     
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.                                                                               2
  605.                                     ------------
  606.                                     How It Works
  607.                                     ------------
  608.     
  609.     You need three things:
  610.     
  611.     1) The Parse-O-Matic program
  612.     2) A Parse-O-Matic "POM" file (to tell Parse-O-Matic what to do)
  613.     3) The input file
  614.     
  615.     The input file might be a report or data file from another program, or text
  616.     captured from a communications session.  Parse-O-Matic can handle many
  617.     types of input.  We've provided several sample input files. For example,
  618.     the file XMPDAT02.TXT comes from the AccPac accounting software.  AccPac is
  619.     a great program, but its export capabilities leave something to be desired.
  620.     Parse-O-Matic can help!
  621.     
  622.     To see detailed demonstrations of how various files can be parsed, enter
  623.     START at the DOS prompt (or run START.BAT from Windows or OS/2), then
  624.     select TUTORIAL from the menu.
  625.     
  626.                                  -----------------
  627.                                  How To Contact Us
  628.                                  -----------------
  629.     
  630.     If you have any questions about Parse-O-Matic, you can write to us at the
  631.     following address:
  632.     
  633.              Pinnacle Software, CP386, Mount Royal, QC, Canada H3P 3C6
  634.     
  635.     You can also contact us electronically at the following addresses:
  636.     
  637.                         Voice Line: 514-345-9578
  638.                     Internet Email: psoftinfo@aol.com
  639.                     World Wide Web: http://users.aol.com/psoftinfo
  640.                         CompuServe: 70154,1577
  641.     
  642.     
  643.     
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.                                                                               3
  660.     ============================================================================
  661.                                     FUNDAMENTALS
  662.     ============================================================================
  663.     
  664.     
  665.     This documentation assumes that you are an experienced computer user.  If
  666.     you have trouble, you might ask a programmer to help you -- POM file
  667.     creation is a little like programming!
  668.     
  669.                              -------------------------
  670.                              The Parse-O-Matic Command
  671.                              -------------------------
  672.     
  673.     The basic format of the Parse-O-Matic command line is:
  674.     
  675.     POM pom-file input-file output-file
  676.     
  677.     Here is an example, as you would type it at the DOS command line, or as a
  678.     command in a batch file:  POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  679.     
  680.     For a more formal description of the command line, start up POM by typing
  681.     this command at the DOS prompt:  POM
  682.     
  683.     Another method of calling the POM command is to specify a job (.POJ) file.
  684.     This is explained later, in the "File Handling" chapter -- see
  685.     "Parse-O-Matic Job (POJ) Files".  Briefly, a job file lets you save the
  686.     Parse-O-Matic command-line specifications in a text file.
  687.     
  688.                                     ------------
  689.                                     The POM File
  690.                                     ------------
  691.     
  692.     The POM file is a text file with a .POM extension.  The following
  693.     conventions are used when interpreting the POM file:
  694.     
  695.     - Null lines and lines starting with a semi-colon (comments) are ignored.
  696.     
  697.     - A POM file may contain up to 750 lines of specifications.
  698.       Comment lines do not count in this total.
  699.     
  700.     A POM file does not rely on "loops" (to use the programming term).  Each
  701.     line or record of the input file is processed by the entire POM file.  If
  702.     you would like this expressed in terms of programming languages, here is
  703.     what POM does:
  704.     
  705.     +-------------------------------------------------------------------------+
  706.     |      START: If there's nothing left in the input file, go to QUIT.      |
  707.     |             Read a line from the input file                             |
  708.     |             Do everything in the POM file                               |
  709.     |             Go to START                                                 |
  710.     |      QUIT:  Tell the user you are finished!                             |
  711.     +-------------------------------------------------------------------------+
  712.     
  713.  
  714.                                                                               4
  715.     The method by which Parse-O-Matic finds the POM file is discussed in the
  716.     section "How Parse-O-Matic Searches for a File".
  717.     
  718.                                 -------------------
  719.                                 Padding for Clarity
  720.                                 -------------------
  721.     
  722.     Spaces and tabs between the words and variables in a POM file line are
  723.     generally ignored (except in the case of the "output picture" of the OUT
  724.     and OUTEND commands).  You can use spaces to make the commands in your POM
  725.     files easier to read.
  726.     
  727.     Additionally, in any line in the POM file, the following terms are ignored:
  728.     
  729.     THEN   ELSE
  730.     
  731.     (There is a POM command named ELSE, but Parse-O-Matic can tell that this is
  732.     not "padding".)
  733.     
  734.     Finally, the equals ("=") character is ignored if it is found in a place
  735.     where no comparison is taking place.  This will be demonstrated below.
  736.     
  737.     You can use these techniques to make your POM files easier to read.  For
  738.     example, the IF command can be written in several ways:
  739.     
  740.     Very terse:          IF PRICE = "0.00" BONUS "0.00" "1.00"
  741.     
  742.     Padded with spaces:  IF PRICE = "0.00"   BONUS   "0.00"   "1.00"
  743.     
  744.     Fully padded:        IF PRICE = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  745.     
  746.     In the last example, the first equals sign ("=") is a "comparator".  (For
  747.     details about comparators, see the section entitled "Using Comparators".)
  748.     The second equals sign is not really required, but it does make the line
  749.     easier to understand.
  750.     
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.                                                                               5
  770.                                   ----------------
  771.                                   A Simple Example
  772.                                   ----------------
  773.     
  774.     Let's say you have a text file called NAMES.TXT that looks like this:
  775.     
  776.     WILLIAMS   JACK
  777.     SMITH      JOHNNY
  778.     JOHNSON    MARY
  779.     :          :
  780.     Column 1   Column 12
  781.     
  782.     Now let's say you want to switch the columns, so that the first name
  783.     appears first.  Your first step is to create a file using a text editor.
  784.     The file would look like this:
  785.     
  786.     SET    last  = $FLINE[ 1 10]
  787.     SET    first = $FLINE[12 17]
  788.     PAD    first "R" " " "10"
  789.     OUTEND |{first} {last}
  790.     
  791.     The first two lines tell Parse-O-Matic to which text to extract from each
  792.     input line.  For the first line of the input file, the variable named
  793.     'last' will be given the value "WILLIAMS  ".  You will notice there are two
  794.     spaces at the end.  That is because we take every character from position 1
  795.     to position 10 -- which in this case includes two spaces.
  796.     
  797.     The PAD line adds enough spaces on the right side of the variable named
  798.     'first' to make sure that it is 10 characters long.  The OUTEND command
  799.     sends the two variables to the output file.
  800.     
  801.     Save the file with the name TEST.POM and exit your text editor.  At the DOS
  802.     prompt, enter this command:
  803.     
  804.     POM TEST.POM NAMES.TXT OUTPUT.TXT
  805.     
  806.     This will run the POM file (TEST.POM) on every line of the input file
  807.     (NAMES.TXT) and place the output in the file OUTPUT.TXT, which will then
  808.     look like this:
  809.     
  810.     JACK       WILLIAMS
  811.     JOHNNY     SMITH
  812.     MARY       JOHNSON
  813.     :          :
  814.     Column 1   Column 12
  815.     
  816.     Of course, for such a simple task, it would be easier to switch the columns
  817.     yourself, using a text editor.  But when you are dealing with large amounts
  818.     of data, and want to guard against typing errors, Parse-O-Matic can save
  819.     you a lot of time, effort and risk.  It also lets you automate editing
  820.     operations that you perform frequently.
  821.     
  822.  
  823.  
  824.                                                                               6
  825.     ============================================================================
  826.                                   QUICK REFERENCE
  827.     ============================================================================
  828.     
  829.                                 --------------------
  830.                                 Command Descriptions
  831.                                 --------------------
  832.     
  833.     This manual's explanations of the commands are grouped by related functions,
  834.     in the following order:
  835.     
  836.     ---------------------------------------------------------------------------
  837.     Basic Commands
  838.     ---------------------------------------------------------------------------
  839.     SET       Assigns a value to a variable
  840.     IF        Conditionally assigns a value to a variable
  841.     
  842.     ---------------------------------------------------------------------------
  843.     Output Commands
  844.     ---------------------------------------------------------------------------
  845.     KEEP      Do a page eject if less than the specified number of lines remain
  846.     OFILE     Specify output file or device
  847.     OUT       Sends text and variables to the output file
  848.     OUTEND    Like OUT but adds a new line at end (Carriage Return/Linefeed)
  849.     OUTHDG    Sets up title lines to appear at the top of a report or each page
  850.     OUTPAGE   Starts a new page
  851.     PAGELEN   Sets the page length for a report
  852.     
  853.     ---------------------------------------------------------------------------
  854.     Input Commands
  855.     ---------------------------------------------------------------------------
  856.     GET       Manually reads bytes from the input file
  857.     GETTEXT   Manually reads bytes from the input file, converts them to text
  858.     READNEXT  Moves to next input line but retains your place in the POM file
  859.     REWIND    Backs up a specified number of bytes in an input file
  860.     
  861.     ---------------------------------------------------------------------------
  862.     Input Filters
  863.     ---------------------------------------------------------------------------
  864.     MINLEN    Sets minimum length required for an input line to be processed
  865.     IGNORE    Ignores an input line that meets the specified condition
  866.     ACCEPT    Accepts an input line that meets the specified condition
  867.     
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.                                                                               7
  880.     ---------------------------------------------------------------------------
  881.     Flow Control Commands
  882.     ---------------------------------------------------------------------------
  883.     BEGIN     Defines the conditions for processing the code block
  884.     CALL      Calls a subroutine code block
  885.     CODE      Marks the start of a subroutine code block
  886.     ELSE      Defines the start of code to be processed if the BEGIN fails
  887.     END       Marks the end of a BEGIN/END or BEGIN/ELSE/END code block
  888.     AGAIN     Conditionally returns to the corresponding BEGIN command
  889.     DONE      Reads the next input line and starts at the top of the POM file
  890.     NEXTFILE  Skips the current input file and proceeds to the next one
  891.     HALT      Terminates all processing if a given condition exists
  892.     PROLOGUE  Defines code block to run before input lines are processed
  893.     EPILOGUE  Defines code block to run after  input lines are processed
  894.     
  895.     ---------------------------------------------------------------------------
  896.     Variable Modifiers
  897.     ---------------------------------------------------------------------------
  898.     TRIM      Removes a character from the left, right or all of a variable
  899.     PAD       Centers, or left/right-justifies variable to a specified width
  900.     CHANGE    Replaces all occurrences of a string in a variable
  901.     PROPER    Properizes a variable (e.g. "JOHN SMITH" becomes "John Smith")
  902.     INSERT    Inserts a string on the left or right, or at a "found" position
  903.     APPEND    Concatenates several variables into one variable
  904.     OVERLAY   Extends or overwrites portions of a variable
  905.     CVTCASE   Converts a value to uppercase or lowercase
  906.     MAPFILE   Reads a file containing data transformations for REMAP
  907.     REMAP     Transforms sub-strings into other strings
  908.     
  909.     ---------------------------------------------------------------------------
  910.     Free-Form Commands
  911.     ---------------------------------------------------------------------------
  912.     PARSE     Obtains a variable found between delimiters in free-form data
  913.     PEEL      Works like PARSE, but removes the "found" text from the data
  914.     
  915.     ---------------------------------------------------------------------------
  916.     Positional Commands
  917.     ---------------------------------------------------------------------------
  918.     SETLEN    Sets a variable according to the length of a value
  919.     DELETE    Removes a range of characters from a variable
  920.     COPY      Copies a range of characters from a value to a variable
  921.     EXTRACT   Like COPY, but removes the characters from the source variable
  922.     FINDPOSN  Finds the starting or ending position of a value in another
  923.     SCANPOSN  Finds "best match" in list of values, returns start/end positions
  924.     
  925.     ---------------------------------------------------------------------------
  926.     Date Commands
  927.     ---------------------------------------------------------------------------
  928.     TODAY     Sets a variable to today's date, in a variety of formats
  929.     DATE      Sets a given year, month and day, in a variety of formats
  930.     MONTHNUM  Sets the month number of a given month, expressed as text
  931.     
  932.  
  933.  
  934.                                                                               8
  935.     ---------------------------------------------------------------------------
  936.     Calculation Commands
  937.     ---------------------------------------------------------------------------
  938.     CALC      Performs arithmetic functions on integer values
  939.     CALCREAL  Performs arithmetic functions on decimal values
  940.     ROUNDING  Controls rounding in CALCREAL operations
  941.     
  942.     ---------------------------------------------------------------------------
  943.     Input Preprocessors
  944.     ---------------------------------------------------------------------------
  945.     SPLIT     Breaks up a wide text file (more than 255 characters)
  946.     CHOP      Breaks up a fixed-record-length file
  947.     
  948.     ---------------------------------------------------------------------------
  949.     Lookup Commands
  950.     ---------------------------------------------------------------------------
  951.     LOOKUP    Looks up a word in another file and returns a corresponding value
  952.     LOOKFILE  Specifies the file that the LOOKUP command will use (see also /L)
  953.     LOOKCOLS  Specifies the format of the look-up file
  954.     LOOKSPEC  Controls the behaviour of the LOOKUP command
  955.     
  956.     ---------------------------------------------------------------------------
  957.     Data Converters
  958.     ---------------------------------------------------------------------------
  959.     MAKEDATA  Converts text into binary format
  960.     MAKETEXT  Converts binary format into text
  961.     
  962.     ---------------------------------------------------------------------------
  963.     Miscellaneous Commands
  964.     ---------------------------------------------------------------------------
  965.     ERASE     Deletes a file
  966.     FILESIZE  Obtains the size of a file (in bytes)
  967.     GETENV    Obtains a system environment variable (e.g. PATH)
  968.     LOG       Adds a line to the processing log
  969.     MSGWAIT   Controls the behaviour of error messages
  970.     PAUSE     Delays the specified number of milliseconds
  971.     RANDOM    Generates a random number
  972.     SHOWNOTE  Displays a message on the processing screen
  973.     SOUND     Makes a noise or sets the noise generated by error messages
  974.     TRACE     Traces a variable (results saved in the text file POM.TRC)
  975.     
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.                                                                               9
  990.                                   ---------------
  991.                                   Command Formats
  992.                                   ---------------
  993.     
  994.     ----------------------------------  ---------------------------------------
  995.     COMMAND FORMATS                     EXAMPLE
  996.     ----------------------------------  ---------------------------------------
  997.     ACCEPT   val c val                  ACCEPT   $FLINE[1 3] = "YES"
  998.     AGAIN    [val c val]                AGAIN    linecntr #< "3"
  999.     APPEND   var val val [val [val]]    APPEND   name first last
  1000.     BEGIN    [val c val]                BEGIN    linecntr #< "3"
  1001.     CALL     val                        CALL     "Format Price Field"
  1002.     CALC     var num operation num      CALC     total total "+" sold
  1003.     CALCBITS var char operation char    CALCBITS z byte1 "XOR" $80
  1004.     CALCREAL var num operation num      CALCREAL salary hours "*" rate
  1005.     CHANGE   var val val                CHANGE   date "/" "-"
  1006.     CHOP     from to [,from to] [...]   CHOP     1 250, 251 300
  1007.     CODE     val                        CODE     "Format Price Field"
  1008.     COPY     var val from [to]          COPY     x $FLINE "3" "5"
  1009.     CVTCASE  var val [ctl]              CVTCASE  x $FLINE "LA"
  1010.     DATE     var num num num [ctl]      DATE     x "98" "12" "31"
  1011.     DELETE   var from [to]              DELETE   x "3" "5"
  1012.     DONE     [val c val]                DONE     $FLINE = "End Data"
  1013.     ELSE                                ELSE
  1014.     END                                 END
  1015.     EPILOGUE                            EPILOGUE
  1016.     ERASE    file                       ERASE    "C:\MYFILES\OUTPUT.TXT"
  1017.     EXTRACT  var var from [to]          EXTRACT  x $FLINE "15" "30"
  1018.     FILESIZE var file                   FILESIZE x "C:\MYFILES\INPUT.TXT"
  1019.     FINDPOSN var val left [right [ctl]] FINDPOSN x $FLINE "2*/"
  1020.     GET      var ctl [ctl [ctl]]        GET      x #0 "END" "I"
  1021.     GETENV   var val                    GETENV   x "COMSPEC"
  1022.     GETTEXT  var ctl [ctl]              GETTEXT  date "WORD" "DATE"
  1023.     HALT     val c val val [ctl]        HALT     x = y "Item repeated"
  1024.     IF       val c val var val [val]    IF       x = "Y" THEN z = "N"
  1025.     IGNORE   val c val                  IGNORE   price = "0.00"
  1026.     INSERT   var ctl val                INSERT   price "L" "$"
  1027.     KEEP     num                        KEEP     "5"
  1028.     LOG      val c val val [val [val]]  LOG      x = y "Item repeated"
  1029.     LOOKCOLS num num num num            LOOKCOLS "1" "3" "8" "255"
  1030.     LOOKFILE file                       LOOKFILE "C:\TABLES\DATA.TBL"
  1031.     LOOKSPEC ctl ctl ctl                LOOKSPEC "Y" "N" "N"
  1032.     LOOKUP   var val                    LOOKUP   phonenum "FRED JONES"
  1033.     MAKEDATA var val ctl                MAKEDATA x "255" "BYTE"
  1034.     MAKETEXT var val ctl                MAKETEXT z x "BYTE"
  1035.     MAPFILE  file val [ctl]             MAPFILE  "XYZ.MPF" "XYZ" "ANYCASE"
  1036.     MINLEN   num [num]                  MINLEN   "15" "1"
  1037.     MONTHNUM var val                    MONTHNUM x "February"
  1038.     MSGWAIT  num                        MSGWAIT  "60"
  1039.     NEXTFILE [val c val]                NEXTFILE $FLINE = "End File"
  1040.     OFILE    file [val [ctl]]           OFILE    "C:\MYFILES\OUT.TXT"
  1041.     OUT      [val c val] |pic           OUT      z = "X" |{price}
  1042.     OUTEND   [val c val] |pic           OUTEND   z = "X" |{$FLINE}
  1043.  
  1044.                                                                              10
  1045.     OUTHDG   val                        OUTHDG   "LIST OF EMPLOYEES"
  1046.     OUTPAGE  [val c val]                OUTPAGE  partnum <> oldpartnum
  1047.     OVERLAY  var val from               OVERLAY  x "***" "15"
  1048.     PAD      var ctl char num           PAD      sernum "L" "0" "10"
  1049.     PAGELEN  num [ctl]                  PAGELEN  "66" "N"
  1050.     PARSE    var val left right [ctl]   PARSE    x $FLINE "2*(" "3*)" "I"
  1051.     PAUSE    num                        PAUSE    "1000"
  1052.     PEEL     var var left right [ctl]   PEEL     x $FLINE "2*(" "3*)" "I"
  1053.     PROLOGUE                            PROLOGUE
  1054.     PROPER   var [ctl [file]]           PROPER   custname "I" "XY.PEF"
  1055.     RANDOM   var val val                RANDOM   roll "1" "6"
  1056.     READNEXT [val c val]                READNEXT $FLINE[1 5] = "NOTE:"
  1057.     REMAP    var [val]                  REMAP    $FLINE "BIN2CODE"
  1058.     REWIND   [num]                      REWIND   "15"
  1059.     ROUNDING val                        ROUNDING "N"
  1060.     SCANPOSN var var val val [ctl]      SCANPOSN from to $FLINE "/MR/MISS/MRS"
  1061.     SET      var val                    SET      name $FLINE[20 26]
  1062.     SETLEN   var val                    SETLEN   length custname
  1063.     SHOWNOTE val [val] [val] [...]      SHOWNOTE "Processing record #" recnum
  1064.     SOUND    ctl                        SOUND    "BUZZ"
  1065.     SPLIT    from to [,from to] [...]   SPLIT    1 250, 251 300
  1066.     TODAY    var [ctl]                  TODAY    x "?y/?n/?d"
  1067.     TRACE    var                        TRACE    price
  1068.     TRIM     var ctl char               TRIM     price "R" "$"
  1069.     ZERODATE num num num                ZERODATE "1753" "12" "31"
  1070.     ----------------------------------  ---------------------------------------
  1071.     
  1072.     The following conventions are used in the preceding table:
  1073.     
  1074.     c      Comparator (if omitted, defaults to "equals" comparison)
  1075.     char   Variable or literal: must be a single byte or character
  1076.     ctl    Variable or literal: command control specifications
  1077.     file   File name (see "How Parse-O-Matic Searches for a File")
  1078.     from   Variable or literal: a starting character position (see Note #1)
  1079.     left   Variable or literal: see "Decapsulators"
  1080.     num    Variable or literal: must contain a number (see Note #1)
  1081.     pic    Output picture used by OUT and OUTEND
  1082.     right  Variable or literal: see "Decapsulators"
  1083.     to     Variable or literal: an ending position (see Note #1)
  1084.     val    Variable or literal whose value is being read
  1085.     var    Variable that is being set
  1086.     [xxx]  Square brackets indicate optional items
  1087.     
  1088.     Note #1:  Tabs, spaces and commas are stripped from numeric values
  1089.     
  1090.     The commands are explained in detail in the following section.  A summary
  1091.     of the commands and default settings appear, as comments, in the file
  1092.     QUICKREF.POM.  You can copy these comments into your own POM file as
  1093.     a convenient quick reference.
  1094.     
  1095.     
  1096.     
  1097.  
  1098.  
  1099.                                                                              11
  1100.     ============================================================================
  1101.                                    BASIC COMMANDS
  1102.     ============================================================================
  1103.     
  1104.                                   ---------------
  1105.                                   The SET Command
  1106.                                   ---------------
  1107.     
  1108.     FORMAT:        SET var1 value1
  1109.     
  1110.     PURPOSE:       SET assigns a value1 to a the variable var1.
  1111.     
  1112.     ALTERNATIVES:  The COPY command
  1113.     
  1114.     The usual reason to use the SET command is to set a variable from the input
  1115.     line (represented by the variable $FLINE) prior to cleaning it up with
  1116.     TRIM. For example, if the input line looked like this:
  1117.     
  1118.     JOHN       SMITH     555-1234   322 Westchester Lane    Architect
  1119.     |          |         |          |                       |
  1120.     Column 1   Col 12    Col 22     Col 33                  Col 57
  1121.     
  1122.     then we could extract the last name from the input line with these two POM
  1123.     commands:
  1124.     
  1125.     SET  NAME = $FLINE[12 21]      (Sets the variable from the input line)
  1126.     TRIM NAME  "R"  " "            (Trims any spaces on the right side)
  1127.     
  1128.     SET would first set the variable NAME to this value:     "SMITH     "
  1129.     After the TRIM, the variable NAME would have the value:  "SMITH"
  1130.     
  1131.     You will also use SET if you plan to include a portion of text string in
  1132.     the output, since the OUT and OUTEND commands do not recognize substrings
  1133.     after the "|" marker; they only recognize plain text and complete
  1134.     variables.
  1135.     
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.                                                                              12
  1155.                                    --------------
  1156.                                    The IF Command
  1157.                                    --------------
  1158.     
  1159.     FORMAT:        IF value1 [comparator] value2 var1 value3 [value4]
  1160.     
  1161.     PURPOSE:       If value1 equals value2, var1 is set to value3.  Otherwise,
  1162.                    it is set to value4 (if value4 is missing, nothing is done,
  1163.                    and var1 is not changed).
  1164.     
  1165.     NOTES:         For an explanation of comparators, see "Using Comparators".
  1166.                    In the following explanation, we will demonstrate the
  1167.                    command using only the "literally identical" ("=")
  1168.                    comparator.
  1169.     
  1170.     ALTERNATIVES:  The BEGIN command
  1171.     
  1172.     Here is an example of the IF command...
  1173.     
  1174.     SET  EARNING = $FLINE[20 23]
  1175.     IF   EARNING = "0.00" THEN BONUS = "0.00" ELSE "1.00"
  1176.     
  1177.     This obtains the value between columns 20 and 26, then checks if it equals
  1178.     "0.00".  If it does, the variable BONUS is set to 0.00.  If not, BONUS is
  1179.     set to "1.00".  The "THEN" and "ELSE" are "padding" and can be omitted.
  1180.     
  1181.     
  1182.     
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.                                                                              13
  1210.     ============================================================================
  1211.                                   OUTPUT COMMANDS
  1212.     ============================================================================
  1213.     
  1214.                                   ----------------
  1215.                                   The KEEP Command
  1216.                                   ----------------
  1217.     
  1218.     FORMAT:        KEEP value1
  1219.     
  1220.     PURPOSE:       KEEP does a page eject if less than the specified number of
  1221.                    lines remain on the page.
  1222.     
  1223.     PARAMETERS:    value1 is the minimum number of lines required to avoid doing
  1224.                    a page eject.
  1225.     
  1226.     ALTERNATIVES:  The OUTPAGE command, used with $LINECOUNTER
  1227.     
  1228.     NOTES:         KEEP has no effect unless the page length is set, using the
  1229.                    PAGELEN command.
  1230.     
  1231.     SEE ALSO:      "The OutHdg Command"
  1232.     
  1233.     When you are sending output to a file that will be printed (or sending
  1234.     output directly to a printer -- see "How Parse-O-Matic Opens an Output
  1235.     File"), you sometimes want to ensure that certain lines of data are kept
  1236.     together on the same page.  The most common situation involves a heading
  1237.     that precedes some associated data; you do not want to have the heading by
  1238.     itself at the bottom of one page, with the data on the next. Consider this
  1239.     POM file:
  1240.     
  1241.     PAGELEN  "55"                        <-- Set the output page length
  1242.     SET      part     = $FLINE[ 1 10]    <-+
  1243.     SET      type     = $FLINE[12 20]      | Extract the fields
  1244.     SET      quantity = $FLINE[22 30]    <-+
  1245.     BEGIN    lasttype <> type            <-- Detect a change in part type
  1246.       SET      lasttype = part           <-- Remember this part type
  1247.       KEEP     "4"                       <-- Make sure we have 4 lines left
  1248.       OUTEND   |                         <-- Output a blank line
  1249.       OUTEND   |PART TYPE:  {type}       <-- Output a header
  1250.     END                                  <-- End of code block
  1251.     OUTEND   {part} {quantity}           <-- Output part data
  1252.     
  1253.     This POM file will always make sure that at least two part numbers follow
  1254.     the heading; a heading will never be "stranded" by itself at the end of a
  1255.     page.
  1256.     
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.                                                                              14
  1265.                                  -----------------
  1266.                                  The OFILE Command
  1267.                                  -----------------
  1268.     
  1269.     FORMAT:        OFILE value1
  1270.                    OFILE value1 [value2 [value3]]
  1271.     
  1272.     PURPOSE:       OFILE specifies a new output file or device.
  1273.     
  1274.     PARAMETERS:    value1 is the name of the output file or device
  1275.                    value1 can also be a subcommand (i.e. a command for OFILE)
  1276.                    value2 is the default extension for the DEDUCE subcommand
  1277.                    value3 is the control value for the DEDUCE subcommand
  1278.     
  1279.     DEFAULTS:      value2 defaults to "" for the DEDUCE subcommand
  1280.                    value3 defaults to "WEAK" for the DEDUCE subcommand
  1281.     
  1282.     ALTERNATIVES:  Specify the name of the output file on the POM command line
  1283.     
  1284.     SEE ALSO:      "How Parse-O-Matic Opens an Output File"
  1285.                    "Sending Output to a Device"
  1286.     
  1287.     When you start up Parse-O-Matic, you can specify the name of the output
  1288.     file on the command line.  For example:
  1289.     
  1290.     POM MYPOM.POM INPUT.TXT OUTPUT.TXT
  1291.     
  1292.     In this case, the output file is named OUTPUT.TXT.  All data from the
  1293.     output commands (OUT, OUTEND etc.) are sent to this file.  If you omit the
  1294.     output file name from the POM command, like this:
  1295.     
  1296.     POM MYPOM.POM INPUT.TXT
  1297.     
  1298.     then Parse-O-Matic assumes the output file is named POMOUT.TXT (in the
  1299.     current directory).
  1300.     
  1301.     -----------
  1302.     Basic Usage
  1303.     -----------
  1304.     
  1305.     Once the name of the output file has been determined, Parse-O-Matic will
  1306.     use that file until it is changed, using the OFILE command.  For example:
  1307.     
  1308.     OFILE "C:\XYZ.TXT"
  1309.     
  1310.     This will change the output file to C:\XYZ.TXT.  If the file already
  1311.     exists, it will be renamed with a BAK extension.  However, you can tell
  1312.     Parse-O-Matic to append to the end of an existing file by placing a plus
  1313.     sign in front of the file name:
  1314.     
  1315.     OFILE "+C:\XYZ.TXT"
  1316.     
  1317.  
  1318.  
  1319.                                                                              15
  1320.     (See "Appending to Output Files" and "POM and Wildcards" for additional
  1321.     details on appending to output files).
  1322.     
  1323.     -----------------------
  1324.     Closing the Output File
  1325.     -----------------------
  1326.     
  1327.     Sometimes you want your POM file to explicitly close the output file before
  1328.     doing additional processing.  By closing the file explicitly, you ensure
  1329.     that all output has been written to the disk.
  1330.     
  1331.     To explicitly close the output file, use OFILE's CLOSE subcommand:
  1332.     
  1333.     OFILE "(CLOSE)"
  1334.     
  1335.     It is rarely necessary to explicitly close the output file, since this is
  1336.     done automatically when Parse-O-Matic finishes processing.  You only need to
  1337.     do this if you suspect that a failure may occur between an OUT[END] command
  1338.     and the next OFILE command (or the completion of processing).
  1339.     
  1340.     ----------------
  1341.     Strong Deduction
  1342.     ----------------
  1343.     
  1344.     Sometimes you want to relate the name of the output file to the input file.
  1345.     For example, if the input file is XYZ.TXT, you might want to name the output
  1346.     file XYZ.OUT -- in other words, the same root name (XYZ) but a different
  1347.     extension (OUT).
  1348.     
  1349.     The OFILE command can do this with the DEDUCE subcommand, as follows:
  1350.     
  1351.     OFILE "(DEDUCE)" "OUT" "STRONG"
  1352.     
  1353.     The (DEDUCE) subcommand tells OFILE that you want it to use the same root
  1354.     name as the input file.  The "OUT" part of this example is the extension you
  1355.     want to use.  "STRONG" means that you want to override the existing output
  1356.     file, even if the user specified one on the command line.
  1357.     
  1358.     Here is another example:
  1359.     
  1360.     OFILE "(DEDUCE)" "CSV" "STRONG"
  1361.     
  1362.     This uses the same root name as the input file, but uses the CSV extension
  1363.     (CSV usually signifies a comma-separated-value file).  Once again, the
  1364.     "STRONG" parameter means that the new output file will be opened even if the
  1365.     user specified an output file on the POM command line.
  1366.     
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.                                                                              16
  1375.     --------------
  1376.     Weak Deduction
  1377.     --------------
  1378.     
  1379.     Sometimes you want to set the output file name only if the user has not
  1380.     specified one on the POM command line.  You can do this with OFILE's DEDUCE
  1381.     subcommand:
  1382.     
  1383.     OFILE "(DEDUCE)" "CSV" "WEAK"
  1384.     
  1385.     If the user ran POM with this command:
  1386.     
  1387.     POM MYFILE.POM ACCOUNT.DAT
  1388.     
  1389.     then the output file would be set to ACCOUNT.CSV.  However, if the user
  1390.     explicitly specified an output file:
  1391.     
  1392.     POM MYFILE.POM ACCOUNT.DAT MYOUTPUT.TXT
  1393.     
  1394.     then the weak OFILE command would be ignored and output would continue to
  1395.     be directed to the MYOUTPUT.TXT file.
  1396.     
  1397.     Weak deduction is generally used in the PROLOGUE section of a POM file.  It
  1398.     is particularly useful when wildcards are used (See "POM and Wildcards").
  1399.     Consider this POM command:
  1400.     
  1401.     POM MYFILE.POM *.DAT
  1402.     
  1403.     You could put the following OFILE command in the PROLOGUE:
  1404.     
  1405.     OFILE "(DEDUCE)" "TXT"        <-- "WEAK" is the default deduction
  1406.     
  1407.     This would create a separate output file for each file that is processed.
  1408.     So if you had three DAT files, named A.DAT, B.DAT and C.DAT, you would
  1409.     create three output files, named A.TXT, B.TXT and C.TXT.
  1410.     
  1411.     Because this is a weak deduction, the user is not forced to use your output
  1412.     method.  If the user typed the POM command this way:
  1413.     
  1414.     POM MYFILE.POM *.DAT MYOUTPUT.TXT
  1415.     
  1416.     then all the output (from all of the input files) would go to MYOUTPUT.TXT.
  1417.     
  1418.     NOTE:  When a user does not specify an output file, Parse-O-Matic
  1419.            temporarily assumes that the output file is named POMOUT.TXT. If the
  1420.            user actually types POMOUT.TXT on the command line, Parse-O-Matic
  1421.            treats it as if no output file name had been typed.
  1422.     
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.                                                                              17
  1430.     -------------------
  1431.     Appended Deductions
  1432.     -------------------
  1433.     
  1434.     An alternative to the DEDUCE subcommand is the +DEDUCE subcommand.  This
  1435.     will figure out the output file name as before, but all output will be
  1436.     appended to the end.  This is useful for daily processing when you want to
  1437.     accumulate data in your output file or files.  For example:
  1438.     
  1439.     OFILE "(+deduce)" "txt" "strong"     <-- Note that case does not matter
  1440.     
  1441.     If the user started POM with this command:
  1442.     
  1443.     POM MYFILE.POM ACCOUNT.DAT
  1444.     
  1445.     then the output file would be set to ACCOUNT.TXT, and all output would be
  1446.     placed at the end of the existing file of that name.
  1447.     
  1448.                             ---------------------------
  1449.                             The OUT and OUTEND Commands
  1450.                             ---------------------------
  1451.     
  1452.     FORMAT:        OUT[END] [value1 [comparator] value2] |output-picture
  1453.     
  1454.     PURPOSE:       The OUT command generates output without an end-of-line
  1455.                    (i.e. carriage return and linefeed characters).
  1456.                    The OUTEND command generates output and also adds an
  1457.                    end-of-line.
  1458.     
  1459.     NOTES:         For an explanation of comparators, see "Using Comparators".
  1460.                    In the following explanation, we will demonstrate the
  1461.                    command using only the "literally identical" ("=")
  1462.                    comparator.
  1463.     
  1464.     When value1 equals value2, a line is sent to the output file, according to
  1465.     the output picture.  Within the output picture, all text is taken literally
  1466.     (i.e. " is taken to mean literally that -- a quotation mark character).
  1467.     
  1468.     The only exception to this is variable names, which are identified by the
  1469.     { and } characters.  For example, a POM file that contained the following
  1470.     single line:
  1471.     
  1472.     OUTEND "X" = "X" |{$FLINE}
  1473.     
  1474.     would simply output every line from the input file (not very useful!).
  1475.     
  1476.     The "X" = "X" part of the command is the comparison which controls when
  1477.     output occurs.  In the example above, both values being compared are the
  1478.     same, so output will always occur.
  1479.     
  1480.     You can not use substrings after the "|" marker.  Thus, the following line
  1481.     is NOT legal:  OUTEND $FLINE[1 3] = "IBM" |{$FLINE[1 15]}
  1482.     
  1483.  
  1484.                                                                              18
  1485.     The correct way to code this is as follows:
  1486.     
  1487.     SET CODE = $FLINE[1 15]
  1488.     OUTEND $FLINE[1 3] = "IBM" |{CODE}
  1489.     
  1490.     This outputs the first 15 characters of any line that contains the letters
  1491.     "IBM" in the first three positions.
  1492.     
  1493.     -----------------------
  1494.     Generating a Blank Line
  1495.     -----------------------
  1496.     
  1497.     To send a blank line to a text output file, specify OUTEND without any data
  1498.     following the | marker, as follows:
  1499.     
  1500.     OUTEND |
  1501.     
  1502.     --------------
  1503.     Missing Output
  1504.     --------------
  1505.     
  1506.     If you find that an OUT or OUTEND command is not displaying a variable, but
  1507.     puts "nothing" in its place, check the spelling of the variable name in each
  1508.     place it is used.  Consider this example:
  1509.     
  1510.     SET     varablex = $FLINE[1 12]
  1511.     OUTEND  |XX{variablex}ZZ
  1512.     
  1513.     The SET command spelled "variablex" incorrectly -- it left out the "i". When
  1514.     OUTEND encounters the variable named "variablex", it sees that it does not
  1515.     have a value, so it replaces it with "nothing", yielding the result "XXZZ".
  1516.     
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.                                                                              19
  1540.                                  ------------------
  1541.                                  The OUTHDG Command
  1542.                                  ------------------
  1543.     
  1544.     FORMAT:        OUTHDG value1
  1545.     
  1546.     PURPOSE:       OUTHDG is used to place text headers in your output.
  1547.     
  1548.     ALTERNATIVES:  The OUTEND command, used with PROLOGUE
  1549.     
  1550.     SEE ALSO:      "The PageLen Command" and "The OutPage Command"
  1551.     
  1552.     If you were parsing data to create an employee report, you might use OUTHDG
  1553.     like this:
  1554.     
  1555.     SET EMPNUM = $FLINE[ 1  5]
  1556.     SET NAME   = $FLINE[10 28]
  1557.     SET PHONE  = $FLINE[30 45]
  1558.     OUTHDG "EMPL#  NAME                PHONE NUMBER"
  1559.     OUTHDG "-----  ------------------- ------------"
  1560.     OUTEND |{EMPNUM} {NAME} {PHONE}
  1561.     
  1562.     The value following the OUTHDG command is sent to the output file only
  1563.     once.  That is to say, after an OUTHDG sends a value to the output file,
  1564.     subsequent encounters with that OUTHDG command are ignored -- unless the
  1565.     PAGELEN command is used.
  1566.     
  1567.     To specify a blank line in a heading, use the following command:  OUTHDG ""
  1568.     
  1569.     If your output is bound for a continuous-paper printer (e.g. a dot-matrix
  1570.     printer with tractor feed), you may find it useful to use one or more blank
  1571.     lines at the beginning of the header, in order to skip over the perforation
  1572.     in the paper.
  1573.     
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.                                                                              20
  1595.                                 -------------------
  1596.                                 The OUTPAGE Command
  1597.                                 -------------------
  1598.     
  1599.     FORMAT:        OUTPAGE  [value1 [comparison] value2]
  1600.     
  1601.     PURPOSE:       Sends a page eject to the output file (or device).
  1602.     
  1603.     NOTES:         For an explanation of comparators, see "Using Comparators".
  1604.     
  1605.     SEE ALSO:      "The Pagelen Command", "The OutHdg Command", "$LINECOUNTER"
  1606.     
  1607.     If the comparison in the OUTPAGE command is true, or if it is omitted,
  1608.     OUTPAGE will send a "page eject" to the output file or device.  (See
  1609.     "Sending Output to a Device")  Some exceptions apply, however.  The page
  1610.     eject is not sent under the following circumstances:
  1611.     
  1612.     - If the comparison is false (e.g. OUTPAGE "Y" = "N")
  1613.     
  1614.     - If the page length is set to "0" (the default).  Use the PAGELEN command
  1615.       to specify a different page length.
  1616.     
  1617.     - If the output file is not yet open.  That is to say, if no output has
  1618.       been sent to the output via one of the other output commands (e.g. OUT,
  1619.       OUTEND, OUTHDG), then OUTPAGE will do nothing. (See "How Parse-O-Matic
  1620.       Opens an Output File")
  1621.     
  1622.     - If the output is already at the top of a page.
  1623.     
  1624.     If form feeds are enabled (via the PAGELEN command), OUTPAGE sends a
  1625.     page eject by sending a Form Feed character (ASCII 12) to the output.
  1626.     
  1627.     If form feeds are not enabled, OUTPAGE sends blank lines (i.e. linefeeds)
  1628.     until the requisite number of lines appear on the page.
  1629.     
  1630.     OUTPAGE does NOT automatically place OUTHDG text at the top of the page.
  1631.     OUTHDG text is not "stored"; it is executed in the POM file at the place
  1632.     it occurs.  Here is an example of using OUTPAGE and OUTHDG together:
  1633.     
  1634.     PAGELEN "55" "Y"
  1635.     SET partnum = $FLINE[ 1  7]
  1636.     SET descrip = $FLINE[12 60]
  1637.     OUTPAGE partnum <> oldpartnum
  1638.     OUTHDG |PARTNUM  DESCRIPTION
  1639.     OUTHDG |-------  -----------
  1640.     OUTEND |{partnum}  {descrip}
  1641.     SET    oldpartnum = partnum
  1642.     
  1643.     This will generate a new page, complete with headings, when the partnum
  1644.     variable is different from the oldpartnum variable.  Also, because of the
  1645.     interaction between OUTHDG and PAGELEN, they headings will appear on a new
  1646.     page if you run out of room on the current page.
  1647.     
  1648.  
  1649.                                                                              21
  1650.                                 -------------------
  1651.                                 The PAGELEN Command
  1652.                                 -------------------
  1653.     
  1654.     FORMAT:        PAGELEN value1 [value2]
  1655.     
  1656.     PURPOSE:       The PAGELEN command specifies the length of the output page.
  1657.     
  1658.     PARAMETERS:    value1 is the page length
  1659.                    value2 specifies if form feeds should be used
  1660.     
  1661.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  1662.     
  1663.     DEFAULTS:      value2 = "Y"
  1664.     
  1665.     When text is sent to an output file by OUTHDG and OUTEND, the lines are
  1666.     counted.  The default value for page length is zero, which means that the
  1667.     output is a single page of infinite length.  As such, OUTHDG headings
  1668.     appear only the first time they are encountered, and OUTPAGE commands
  1669.     are ignored.
  1670.     
  1671.     If you specify a page length greater than zero, OUTHDG headings become
  1672.     re-enabled once the specified number of output lines have been generated,
  1673.     or after an OUTPAGE command is performed.  A typical value is as follows:
  1674.     
  1675.     PAGELEN "55"
  1676.     
  1677.     This is an ideal page length for most laser printers.  Dot matrix printers
  1678.     typically use a page length of 66.
  1679.     
  1680.     Parse-O-Matic inserts a "form feed" (ASCII 12) character between pages.
  1681.     You can turn this off, however, by specifying the page length this way:
  1682.     
  1683.     PAGELEN "66" "N"
  1684.     
  1685.     The "N" specification means, "No, don't use form feeds".  Another
  1686.     acceptable value is "Y", meaning "Yes, use form feeds", but since this is
  1687.     the default, you do not have to specify it.
  1688.     
  1689.     
  1690.     
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.                                                                              22
  1705.     ============================================================================
  1706.                                    INPUT COMMANDS
  1707.     ============================================================================
  1708.     
  1709.                                   ---------------
  1710.                                   The GET Command
  1711.                                   ---------------
  1712.     
  1713.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  1714.     
  1715.     FORMAT:        GET var1 value1 [value2]         (Variable length records)
  1716.                    GET var1 value1 "END" [value3]   (Delimiter-terminated data)
  1717.                    GET var1 "EOF"                   (Detects end-of-file)
  1718.     
  1719.     PURPOSE:       Manually reads bytes from the input file.
  1720.     
  1721.     RESTRICTIONS:  The input file must be described with CHOP or SPLIT.
  1722.     
  1723.     NOTES:         Data is normally read automatically from the input file.
  1724.                    GET is used only when you want precise control of the
  1725.                    reading process.  GET works only with files whose format
  1726.                    is defined by a CHOP or SPLIT command.  (You can read a
  1727.                    file a byte at a time by using CHOP 1-1 in your POM file.
  1728.                    You can also use CHOP 0 to do all reading manually.)
  1729.     
  1730.     SEE ALSO:      "The Chop Command" and "The Split Command"
  1731.     
  1732.     The GET command is especially helpful for:
  1733.     
  1734.     1) Variable length records
  1735.     2) Delimiter-terminated data (such as zero-terminated text strings)
  1736.     3) Text files with embedded binary data
  1737.     
  1738.     These methods are described in detail below.
  1739.     
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.                                                                              23
  1760.     -----------------------
  1761.     Variable Length Records
  1762.     -----------------------
  1763.     
  1764.     FORMAT:        GET var1 value1 [value2]
  1765.     
  1766.     PURPOSE:       Reads a variable-length record.
  1767.     
  1768.     PARAMETERS:    var1    is the variable being set
  1769.                    value1  specifies how many bytes to read, expressed as:
  1770.                            A value in text format (example:  GET x "10")
  1771.                            A predefined data type (example:  GET x "INTEGER")
  1772.                            A value in byte format (example:  GET x len "BYTE")
  1773.                    value2  specifies the data representation used by value1
  1774.                            This can be "TEXT" (the default) or "BYTE"
  1775.                            May also include "STRICT" (the default) or "LOOSE"
  1776.     
  1777.     NUMERICS:      Tabs, spaces and commas are stripped from value1, if it is
  1778.                    numeric, and in text format
  1779.     
  1780.     DEFAULTS:      value2 = "TEXT"
  1781.     
  1782.     SEE ALSO:      "Predefined Data Types"
  1783.     
  1784.     GET can read up to 255 bytes into a variable, as specified by value1.
  1785.     For example:
  1786.     
  1787.     GET xyz "10"
  1788.     
  1789.     This reads 10 bytes from the input file into the xyz variable, and advances
  1790.     the file pointer.  That is to say, after the GET command shown above is
  1791.     executed, the next data Parse-O-Matic reads will be 10 bytes further along.
  1792.     
  1793.     If the requested number of bytes is not available in the input file,
  1794.     Parse-O-Matic terminates with an error message.
  1795.     
  1796.     In a typical application, variable-length data is preceded in the input
  1797.     file by a byte that gives its length.  You can read the length, then use
  1798.     it directly, as follows:
  1799.     
  1800.     GET len "1" "TEXT"               <-- Get the length byte
  1801.     GET xyz len "BYTE"               <-- Read in the data
  1802.     
  1803.     In the first command, the word "TEXT" means that the length specification
  1804.     (i.e. "1") is plain text.  ("TEXT" is the default, so you can omit it.)
  1805.     
  1806.     In the second command, GET reads len bytes from the input file.  The word
  1807.     "BYTE" means that the length specification is a binary number, not a text
  1808.     string.
  1809.     
  1810.     To clarify this, let us assume that the input file contains a length byte
  1811.     (say hex 4F, which equals 79 in decimal).  This is followed by 79 bytes of
  1812.     data.  The first GET command (GET len "1") reads in the length byte (hex 4F
  1813.  
  1814.                                                                              24
  1815.     or decimal 79).  The second GET command (GET xyz len "BYTE") reads 79 bytes
  1816.     and places the result in the xyz variable.
  1817.     
  1818.     The maximum variable length that a single GET command can handle is 255
  1819.     bytes (i.e. the largest number represented by a single byte).
  1820.     
  1821.     Here are some additional examples of the GET command:
  1822.     
  1823.     SAMPLE COMMAND     EXPLANATION
  1824.     -----------------  -----------
  1825.     GET x "5" "TEXT"   Reads 5 bytes into the x variable
  1826.     GET x "5"          Same as above (since "TEXT" is the default)
  1827.     GET x len          In this case, len must contain a text number (e.g. "7")
  1828.     GET x len "BYTE"   In this case, len must be a byte (i.e. binary format)
  1829.     
  1830.     When the number is in "TEXT" format, spaces and tabs are ignored. Thus, the
  1831.     following command is valid:
  1832.     
  1833.     GET abc " 5 " "TEXT"
  1834.     
  1835.     You can also specify the length of the data as a predefined data type (see
  1836.     "Predefined Data Types" and "The MakeData Command").  Some examples...
  1837.     
  1838.     SAMPLE COMMAND     EXPLANATION
  1839.     -----------------  -----------
  1840.     GET x "INTEGER"    Reads in an integer value (2 bytes long)
  1841.     GET x "SHORTINT"   Reads in a short integer value (1 byte long)
  1842.     GET x "BYTE"       Reads in a byte value (1 byte long)
  1843.     GET x "LONGINT"    Reads in a long integer (4 bytes long)
  1844.     GET x "REAL"       Reads in a real value (6 bytes long)
  1845.     GET x "REAL 2"     Same as above (the decimal precision value 2 is ignored)
  1846.     
  1847.     TECHNICAL NOTE:  In some applications, you will find that a variable-length
  1848.     record may be followed by a "noise" byte. This can occur if the program
  1849.     that created the input file "aligns data to word boundaries" and the record
  1850.     you are reading has an odd number of bytes.  In such case, your POM file
  1851.     must determine (using CALC commands) if the length byte is odd or even, and
  1852.     react accordingly.
  1853.     
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.                                                                              25
  1870.     -------------------------
  1871.     Delimiter-Terminated Data
  1872.     -------------------------
  1873.     
  1874.     FORMAT:        GET var1 value1 "END" [value3]
  1875.     
  1876.     PURPOSE:       Reads delimiter-terminated data from the input file.
  1877.     
  1878.     PARAMETERS:    var1    is the variable being set
  1879.                    value1  is the terminating character you are searching for
  1880.                    "END"   means you are searching for a terminating character
  1881.                    value3  is "I" (for Include) or "X" (for eXclude)
  1882.     
  1883.     DEFAULTS:      value3 = "X"
  1884.     
  1885.     ALTERNATIVES:  The PARSE and PEEL commands
  1886.                    The FINDPOSN command used with the COPY command
  1887.     
  1888.     One common way to represent variable-length text data in a file is to
  1889.     terminate the text string with the null (ASCII 0) character.  You can
  1890.     read in this kind of data with the GET command, as follows:
  1891.     
  1892.     GET abc #0 "END"           <-- #0 means ASCII zero (See "Values")
  1893.     
  1894.     This reads the input file until the null (ASCII 0) character is found, or
  1895.     until 255 characters have been read in (whichever comes first).
  1896.     
  1897.     The terminating character is not included in the string unless you
  1898.     explicitly request it.  There are two forms of GET command that control
  1899.     this behaviour:
  1900.     
  1901.     GET abc #0 "END" "X"       <-- Exclude the terminating character (default)
  1902.     GET abc #0 "END" "I"       <-- Include the terminating character
  1903.     
  1904.     Here is a sample POM file that reads a data file that consists entirely of
  1905.     zero-terminated strings:
  1906.     
  1907.     CHOP   0                   <-- This means you will handle all file reading
  1908.     GET    abc #0 "END"        <-- Read in the data
  1909.     OUTEND |{abc}              <-- Send the data to the output file
  1910.     
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.                                                                              26
  1925.     ---------------------------------------
  1926.     Handling Long Delimiter-Terminated Data
  1927.     ---------------------------------------
  1928.     
  1929.     If some of the data is more than 255 characters long, you can handle it as
  1930.     follows:
  1931.     
  1932.     CHOP   0                   <-- Handle all file reading manually
  1933.     GET    data #0 "END" "I"   <-- Include the terminating character
  1934.     SETLEN len data            <-- Get the length of the string
  1935.     COPY   lastchar data len   <-- Get the last character
  1936.     BEGIN  lastchar = #0       <-- Test the last character
  1937.       DELETE data len          <-- Remove the last character (the terminator)
  1938.       OUTEND |{data}           <-- Output the string, and start a new line
  1939.     ELSE
  1940.       OUT    |{data}           <-- Output the string, but stay on the same line
  1941.     END
  1942.     
  1943.     All of the examples given above assume that the terminating character is
  1944.     ASCII 0 (i.e. #0), because this is by far the most common terminator.
  1945.     However, you can use other values, if required:
  1946.     
  1947.     GET data "X" "END"
  1948.     
  1949.     In actual usage, it is not likely that you will find data strings that are
  1950.     terminated by an "X" character, but the capability is there if the need
  1951.     arises.
  1952.     
  1953.     -------------------------
  1954.     Using GET with Text Files
  1955.     -------------------------
  1956.     
  1957.     While the GET command is normally used with a file which is CHOPped (see
  1958.     "The Chop Command"), you may occasionally find it useful with ordinary text
  1959.     files.  For example, an input file may be almost entirely text (i.e. each
  1960.     line ends with a carriage return and a linefeed), but may also contain some
  1961.     binary data.
  1962.     
  1963.     In such cases, you may find it useful to use the GET command to process the
  1964.     binary data.  However, since GET is not available under standard text
  1965.     processing, you must describe the file with the SPLIT command.  Here is an
  1966.     example which detects and extracts binary data until the character $FF is
  1967.     encountered:
  1968.     
  1969.     SPLIT    1-255                      <-- Process this as a SPLIT file
  1970.     BEGIN    $FLINE[1 10] = "Binary:"   <-- Detect the start of binary data
  1971.       BEGIN                             <-- Start of loop
  1972.         GET    x "1"                    <-- Get a byte
  1973.         OUT    |{x}                     <-- Send it to output
  1974.       AGAIN  x <> $FF                   <-- See if we are finished
  1975.     ELSE                                <-- Handle ordinary text
  1976.       OUTEND   |{$FLINE}                <-- Output ordinary text
  1977.     END                                 <-- End of BEGIN/ELSE/END code block
  1978.  
  1979.                                                                              27
  1980.     Note that SPLIT 1-255 does not mean that each text line is 255 characters
  1981.     long; it means that each line is UP TO 255 characters long.
  1982.     
  1983.     --------------------------
  1984.     End-of-File Considerations
  1985.     --------------------------
  1986.     
  1987.     When you ask the GET command to get something (e.g. a certain number of
  1988.     bytes), it will normally cause Parse-O-Matic to terminate if it reaches the
  1989.     end of the input file before it has fulfilled its mission.  The assumption
  1990.     here is that when you ask for something, you want precisely that -- not
  1991.     something less.
  1992.     
  1993.     However, in some parsing applications you do not know precisely what "lies
  1994.     ahead" in the input file.  In such cases, you may run up against the end of
  1995.     file unexpectedly.  GET provides two ways to handle this.
  1996.     
  1997.     The first method simply checks to see if you are already at the end of the
  1998.     file:
  1999.     
  2000.     GET x "EOF"
  2001.     
  2002.     This sets the x variable to "Y" (for Yes) if you are at the end of the input
  2003.     file.  Otherwise, it sets the x variable to "N" (for No).  Here is an
  2004.     example, which simply copies a file:
  2005.     
  2006.     CHOP     0             <-- Handle all file-reading manually
  2007.     BEGIN
  2008.       GET      x "EOF"     <-- Check if we're at the end of the input file
  2009.       BEGIN    x = "N"
  2010.         GET      byte "1"  <-- Get a byte
  2011.         OUT      |{byte}   <-- Send it to the output file
  2012.       END
  2013.     AGAIN    x = "N"
  2014.     
  2015.     An alternative method is to use a "LOOSE" GET command, as in this example:
  2016.     
  2017.     CHOP     0
  2018.     BEGIN
  2019.       GET      x "1" "TEXT LOOSE"
  2020.       OUT      |{x}
  2021.     AGAIN    x <> ""
  2022.     
  2023.     The LOOSE parameter tells Parse-O-Matic "don't terminate if you have less
  2024.     than the specified number of bytes".  (The default is "STRICT", but since it
  2025.     IS the default, you never actually have to include it in the command.)
  2026.     Thus, all of the following commands are valid:
  2027.     
  2028.     GET x $05 "BYTE LOOSE"    <-- Get from 0 to 5 bytes of data
  2029.     GET x $05 "BYTE STRICT"   <-- Get exactly 5 bytes of data, or terminate
  2030.     GET x "5" "TEXT LOOSE"    <-- Get from 0 to 5 bytes of data
  2031.     GET x "5" "LOOSE"         <-- Same as "TEXT LOOSE"
  2032.     GET x "1"                 <-- Same as "TEXT STRICT"
  2033.  
  2034.                                                                              28
  2035.                                 -------------------
  2036.                                 The GETTEXT Command
  2037.                                 -------------------
  2038.     
  2039.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  2040.     
  2041.     FORMAT:        GETTEXT var1 value1 [value2]
  2042.     
  2043.     PURPOSE:       Manually reads bytes from the input file, then converts
  2044.                    them into text format.
  2045.     
  2046.     PARAMETERS:    var1   is the variable being set
  2047.                    value1 is the predefined data type in the input file
  2048.                    value2 is the MAKETEXT "convert from" parameter
  2049.     
  2050.     DEFAULTS:      If value2 is omitted, it is assumed to be the same as value1
  2051.     
  2052.     NOTES:         Before studying this command, you should already be familiar
  2053.                    with the GET and MAKETEXT commands.
  2054.     
  2055.     SEE ALSO:      "Predefined Data Types"
  2056.     
  2057.     When reading a binary file, you frequently need to read numeric values then
  2058.     convert them to text.  For example:
  2059.     
  2060.     GET      x "WORD"             <-- Read a two-byte number from the file
  2061.     MAKETEXT y x "WORD"           <-- Convert it into text form
  2062.     
  2063.     You can do both of these operations at once, using the GETTEXT command:
  2064.     
  2065.     GETTEXT  y "WORD"
  2066.     
  2067.     This reads a "WORD" (two binary bytes) from the input file, and then
  2068.     converts it into text (e.g. "1234").
  2069.     
  2070.     You only need to use value2 if you are converting a number to a text-based
  2071.     data type such as "DATE".  For example:
  2072.     
  2073.     ZERODATE "1936" "1" "1"                <-- Set "day zero"
  2074.     GETTEXT  date "LONGINT" "DATE Y/M/?d"  <-- Get and convert a date
  2075.     
  2076.     The GETTEXT command is also helpful if you are reading text data from a
  2077.     fixed-length field, but it is padded with spaces or nulls:
  2078.     
  2079.     GETTEXT  x "80" "TRIMMED"
  2080.     
  2081.     This reads in 80 characters, then removes tabs, spaces and nulls from
  2082.     either end of the string.
  2083.     
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.                                                                              29
  2090.                                 --------------------
  2091.                                 The READNEXT Command
  2092.                                 --------------------
  2093.     
  2094.     FORMAT:        READNEXT [value [comparator] value]
  2095.     
  2096.     PURPOSE:       The READNEXT command gets the next line of the input file
  2097.                    (in other words, it replaces the current $FLINE), while
  2098.                    maintaining your place in the POM file.
  2099.     
  2100.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2101.     
  2102.     SEE ALSO:      "The MinLen Command" and "Line Counters"
  2103.     
  2104.     READNEXT is helpful if you know for certain what type of information the
  2105.     next line will contain.  Here is an example:
  2106.     
  2107.     SET note = ""
  2108.     SET customer = $FLINE[1 20]
  2109.     BEGIN $FLINE ^ "See note below"
  2110.       READNEXT
  2111.       SET note = $FLINE[1 20]
  2112.     END
  2113.     OUTEND |{customer} {note}
  2114.     
  2115.     If the input line contains the words "See note below", Parse-O-Matic will
  2116.     read the next line of the input file (replacing the current $FLINE), thus
  2117.     obtaining the comment about the customer.
  2118.     
  2119.     ----------------------
  2120.     End of File Conditions
  2121.     ----------------------
  2122.     
  2123.     If you do a READNEXT at the end of the input file, READNEXT will set $FLINE
  2124.     to null ("").  The POM file will continue processing.
  2125.     
  2126.     --------------------
  2127.     Optional Comparisons
  2128.     --------------------
  2129.     
  2130.     READNEXT can make a comparison.  This is useful for skipping extraneous
  2131.     lines of input.  For example:
  2132.     
  2133.     READNEXT $FLINE[1 5] = "NOTE:"
  2134.     
  2135.     This obtains the next input line if the current input line starts with
  2136.     "NOTE:".
  2137.     
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.                                                                              30
  2145.     -------------------
  2146.     Ignoring Null Lines
  2147.     -------------------
  2148.     
  2149.     By default, READNEXT will read null lines from the input file.  If you want
  2150.     it to ignore null lines, you can use an optional parameter of the MINLEN
  2151.     command to specify a minimum length for the READNEXT command.  For details,
  2152.     see "The MinLen Command".
  2153.     
  2154.     If you are reading a DBF (DBase) file, you can not "ignore null lines",
  2155.     because the data is not in line format.  In such case, you must check a
  2156.     particular field to see if it is null.  (See "DBF Files")
  2157.     
  2158.     If you are using the CHOP or SPLIT commands, it may not be particularly
  2159.     useful to "ignore null lines", since by definition you are requesting a
  2160.     particular number of bytes each time the input is read.  Nevertheless,
  2161.     if you do a READNEXT at the end of the input file, READNEXT will set $FLINE
  2162.     to null (""), and continue processing the POM file.
  2163.     
  2164.     ------------------------
  2165.     Saving the Previous Line
  2166.     ------------------------
  2167.     
  2168.     When you do a READNEXT, there is no simple way to return to the previous
  2169.     line of the input file.  You could use the REWIND command, but if you need a
  2170.     line for other work, it is usually much easier to save a copy:
  2171.     
  2172.     SET note = ""
  2173.     SET customer = $FLINE[1 20]
  2174.     SET saveline = $FLINE
  2175.     BEGIN $FLINE ^ "See note below"
  2176.       READNEXT
  2177.       SET note = $FLINE[1 20]
  2178.     END
  2179.     SET    custnum = saveline[22 25]
  2180.     OUTEND |{custnum} {customer} {note}
  2181.     
  2182.     The example above is not very efficient; it would make more sense to extract
  2183.     custnum BEFORE you use READNEXT.  However, in some applications you may find
  2184.     it necessary to save $FLINE before doing a READNEXT.
  2185.     
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.                                                                              31
  2200.                                  ------------------
  2201.                                  The REWIND Command
  2202.                                  ------------------
  2203.     
  2204.     FORMAT:        REWIND [value1]
  2205.     
  2206.     PURPOSE:       REWIND backs up to an earlier point in the input file.
  2207.     
  2208.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  2209.     
  2210.     DEFAULTS:      If value1 is omitted, input file is rewound to the beginning
  2211.     
  2212.     RESTRICTIONS:  The input file must be described with CHOP or SPLIT.
  2213.     
  2214.     SEE ALSO:      "Using GET with Text Files"
  2215.     
  2216.     -----------------------
  2217.     Why REWIND is Necessary
  2218.     -----------------------
  2219.     
  2220.     Normally, when you process an input file, you read forward in the file.
  2221.     However, on occasion you may find it necessary to back up to an earlier
  2222.     point in the file.
  2223.     
  2224.     Here is a typical situation where this is necessary:  you are looking for
  2225.     one of several strings of data, and when you find one of them, you want to:
  2226.     
  2227.     - Back up in the input file, to the beginning of the string you found
  2228.     - Use DONE to start processing the POM file from the top
  2229.     
  2230.     Because you rewound, the processing will include the text that you found.
  2231.     This is a handy alternative to saving the text and appending it to the front
  2232.     of $FLINE -- see "The Leftover Technique" for an example of that method.
  2233.     
  2234.     In another situation, you need to know something near the middle or end of
  2235.     the file, and once you have found out what that is, you want to rewind to
  2236.     the beginning and start processing again.  This is known as "multiple-pass"
  2237.     processing, because you pass through the input file more than once.
  2238.     
  2239.     ------------
  2240.     Using REWIND
  2241.     ------------
  2242.     
  2243.     If REWIND is used without any parameters (or if you specify REWIND "0"),
  2244.     Parse-O-Matic resets the input file to the beginning.  This will usually be
  2245.     done in a BEGIN/END block, because if you reset the file each time you
  2246.     process the POM file, it will run forever.
  2247.     
  2248.     If REWIND is given a numeric parameter, it will back up that many bytes.
  2249.     (If you are processing a text file, remember to include two bytes for
  2250.     carriage return and linefeed, as necessary.)
  2251.     
  2252.  
  2253.  
  2254.                                                                              32
  2255.     If the REWIND command is asked to rewind before the beginning of the file,
  2256.     it simply resets to the top.  For example, if you have read 15 bytes out of
  2257.     the input file, and you issue the command REWIND "99", the next byte you
  2258.     read will be the first byte of the file.
  2259.     
  2260.     -------
  2261.     Example
  2262.     -------
  2263.     
  2264.     Consider this POM file:
  2265.     
  2266.     CHOP     0            <-- Handle all reading manually
  2267.     GET      x "1"        <-- Get a byte
  2268.     GET      x "1"        <-- Get another byte
  2269.     OUT      |{x}         <-- Output the byte
  2270.     REWIND   "1"          <-- Back up one byte
  2271.     GET      x "1"        <-- Get the same byte again
  2272.     OUT      |{x}         <-- Output the byte
  2273.     NEXTFILE              <-- Stop processing this input file
  2274.     
  2275.     The code shown above will output the second character of an input file
  2276.     twice, then stop -- not very useful, except as a demonstration!
  2277.     
  2278.     
  2279.     
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.                                                                              33
  2310.     ============================================================================
  2311.                                    INPUT FILTERS
  2312.     ============================================================================
  2313.     
  2314.                                  ------------------
  2315.                                  The MINLEN Command
  2316.                                  ------------------
  2317.     
  2318.     FORMAT:        MINLEN value1 [value2]
  2319.     
  2320.     PURPOSE:       MINLEN specifies the minimum length an input line must be to
  2321.                    be considered for parsing.
  2322.     
  2323.     PARAMETERS:    value1 is the minimum input line length
  2324.                    value2 is the minimum length for a READNEXT command
  2325.     
  2326.     NUMERICS:      Tabs, spaces and commas are stripped from value1 and value2
  2327.     
  2328.     DEFAULTS:      value2 = "0"
  2329.     
  2330.     SEE ALSO:      "The ReadNext Command"
  2331.     
  2332.     If you omit the MINLEN command, the minimum length is assumed to be 1.
  2333.     That is to say, all lines 1 character or longer will be processed and
  2334.     shorter lines (null lines in other words) will be ignored.
  2335.     
  2336.     MINLEN is useful for ignoring brief information lines that clutter up a
  2337.     report that you are parsing.  For example, in the sample file EXAMPL02.POM,
  2338.     the MINLEN command is set to 85 to ensure that all lines shorter than 85
  2339.     characters long will be ignored.  This simplifies the coding considerably.
  2340.     
  2341.     The longest allowable input line is 255 characters, unless you use the
  2342.     SPLIT or CHOP command (see "The Split Command" and "The Chop Command").
  2343.     
  2344.     The optional setting value2 specifies the minimum length for a READNEXT
  2345.     command.  If omitted, this value is assumed to be "0", meaning that
  2346.     READNEXT will, by default, read null lines.  If you set value2 to "1",
  2347.     READNEXT will keep reading until it finds an input line of 1 or more
  2348.     characters, or hits the end of file.  The value2 setting has no effect
  2349.     if you are reading a DBF (DBase) file.
  2350.     
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.                                                                              34
  2365.                                  ------------------
  2366.                                  The IGNORE Command
  2367.                                  ------------------
  2368.     
  2369.     FORMAT:        IGNORE value1 [comparator] value2
  2370.     
  2371.     PURPOSE:       When the comparison is true, the input line is ignored and
  2372.                    all further processing on the input line stops.
  2373.     
  2374.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2375.     
  2376.     ALTERNATIVES:  The ACCEPT and BEGIN commands
  2377.     
  2378.     Here is a typical application of the IGNORE command:
  2379.     
  2380.     IGNORE $FLINE[3 9] ^ "Date"
  2381.     
  2382.     This skips any input line that contains the word "Date" between columns 3
  2383.     and 9 ($FLINE is the line just read from the input file).
  2384.     
  2385.                                  ------------------
  2386.                                  The ACCEPT Command
  2387.                                  ------------------
  2388.     
  2389.     FORMAT:        ACCEPT value1 [comparator] value2
  2390.     
  2391.     PURPOSE:       The ACCEPT command accepts the input line if the comparison
  2392.                    is true.  value2.  ACCEPT commands can be "clustered" to
  2393.                    allow a series of related tests.
  2394.     
  2395.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2396.                    In the following explanation, we will demonstrate the
  2397.                    command using only the "literally identical" ("=")
  2398.                    comparator.
  2399.     
  2400.     ALTERNATIVES:  The IGNORE command
  2401.     
  2402.     If the entire POM file reads as follows:
  2403.     
  2404.     ACCEPT $FLINE[15 17] = "YES"
  2405.     OUTEND "X" = "X" |{$FLINE}
  2406.     
  2407.     then any input line that contains "YES" starting in column 15 is sent to
  2408.     the output file.  All other lines are ignored.
  2409.     
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.                                                                              35
  2420.     -----------------
  2421.     Clustered Accepts
  2422.     -----------------
  2423.     
  2424.     Sometimes you have to check more than one value to see if the input line is
  2425.     valid.  You do this by using "clustered ACCEPTs", which are several ACCEPT
  2426.     commands in a row.
  2427.     
  2428.     Briefly stated, if you have several ACCEPTs in a row ("clustered"), they
  2429.     are all processed to determine if the input line is acceptable or not.  If
  2430.     even one ACCEPT matches up, the line is accepted.  To express this in more
  2431.     detail...
  2432.     
  2433.     When the comparison is true, the line is accepted, and processing of the
  2434.     POM file continues for that input line, even if the immediately following
  2435.     ACCEPTs do NOT produce a match.  After all, we've already got a match!
  2436.     
  2437.     If value1 does NOT contain value2, Parse-O-Matic looks at the next commmand
  2438.     in the POM file.  If it is not another ACCEPT, the input line is ignored.
  2439.     If it is another ACCEPT, maybe it will product a match -- so Parse-O-Matic
  2440.     moves to that command.
  2441.     
  2442.     The following POM file uses clustered ACCEPTs to accept any line that
  2443.     contains the name "FRED" or "MARY" between columns 5 and 8, or contains the
  2444.     word "MEMBER" between columns 20 and 25.
  2445.     
  2446.     SET    NAME = $FLINE[5 8]         <-- Set the variable
  2447.     ACCEPT NAME = "FRED"              <-- Look for FRED
  2448.     ACCEPT NAME = "MARY"              <-- Look for MARY
  2449.     ACCEPT $FLINE[20 25] = "MEMBER"   <-- Look for MEMBER
  2450.     OUTEND "X" = "X" |{$FLINE}        <-- Output the line if we get this far
  2451.     
  2452.     The following example will NOT work, however:
  2453.     
  2454.     ACCEPT $FLINE[20 25] = "MEMBER"
  2455.     SET    NAME = $FLINE[5 8]
  2456.     ACCEPT NAME = "FRED"
  2457.     ACCEPT NAME = "MARY"
  2458.     OUTEND "X" = "X" |{$FLINE}
  2459.     
  2460.     It will not work because the ACCEPTs are not clustered; if the first ACCEPT
  2461.     fails, the input line is rejected as soon as the SET command is
  2462.     encountered.  The next two ACCEPTs are not reached in such case.
  2463.     
  2464.     
  2465.     
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.                                                                              36
  2475.     ============================================================================
  2476.                                FLOW CONTROL COMMANDS
  2477.     ============================================================================
  2478.     
  2479.                                  -----------------
  2480.                                  The BEGIN Command
  2481.                                  -----------------
  2482.     
  2483.     FORMAT:        The basic format for the BEGIN command is as follows:
  2484.     
  2485.                    BEGIN value1 [comparator] value2
  2486.                    :
  2487.                    Dependant code
  2488.                    :
  2489.                    END
  2490.     
  2491.     PURPOSE:       If the comparison is true (e.g. value1 equals value2), then
  2492.                    the dependant code (the POM lines between the BEGIN and the
  2493.                    END) are executed.  If the comparison is false, then the
  2494.                    dependant code is skipped.
  2495.     
  2496.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2497.                    In the following explanation, we will demonstrate the
  2498.                    command using only the "literally identical" ("=")
  2499.                    comparator.
  2500.     
  2501.     SEE ALSO:      "The Else Command" and "The Again Command"
  2502.     
  2503.     It is traditional in programming to indent code that appears in blocks
  2504.     such as Parse-O-Matic's BEGIN/END technique.  This makes the logic of
  2505.     the POM file easier for us to understand.  For example:
  2506.     
  2507.     BEGIN datatype = "Employee"
  2508.       SET phone    = $FLINE[ 1 10]
  2509.       SET address  = $FLINE[12 31]
  2510.     END
  2511.     
  2512.     BEGIN/END blocks can be nested.  That is to say, you can have BEGIN/END
  2513.     blocks inside other BEGIN/END blocks.  Here is an example, with arrows
  2514.     to indicate the levels of each BEGIN/END block...
  2515.     
  2516.     BEGIN datatype = "Employee"      <---------------------
  2517.       SET phone    = $FLINE[ 1 10]                        |
  2518.       SET address  = $FLINE[12 31]                        |
  2519.       SET areacode = phone[1 3]                           | First
  2520.       BEGIN areacode = "514"         <------- Second      | Level
  2521.         SET local = "Y"                     | Level       | Block
  2522.         SET tax   = "Y"              <------- Block       |
  2523.       END                                                 |
  2524.     END                              <---------------------
  2525.     
  2526.     In this case, the "inner" block (starting with BEGIN areacode = "514") is
  2527.     reached only if the "outer" block (BEGIN datatype = "Employee") is true.
  2528.  
  2529.                                                                              37
  2530.     If the outer block is false, the inner block is ignored.
  2531.     
  2532.     A nested BEGIN/END block must always be completely inside the outer block.
  2533.     Study the following (incorrect) example:
  2534.     
  2535.     BEGIN datatype = "Employee"             <----
  2536.       SET phone    = $FLINE[ 1 10]              |  First
  2537.       SET areacode = phone[1 3]                 |  Level
  2538.       BEGIN areacode = "514"         <---       |  Block?
  2539.         SET local = "Y"                 |       |
  2540.     END                                 |   <----
  2541.       SET tax = "Y"                     |
  2542.       END                            <---  Second Level Block?
  2543.     
  2544.     Parse-O-Matic does not pay attention to the indenting -- it is only a
  2545.     tradition we use to make the file easier to read.  The code will be
  2546.     understood this way:
  2547.     
  2548.     BEGIN datatype = "Employee"      <---------------------
  2549.       SET phone    = $FLINE[ 1 10]                        | First
  2550.       SET areacode = phone[1 3]                           | Level
  2551.       BEGIN areacode = "514"         <--- Second          | Block
  2552.         SET local = "Y"                 | Level           |
  2553.       END                            <--- Block           |
  2554.       SET tax = "Y"                                       |
  2555.     END                              <---------------------
  2556.     
  2557.     You can nest BEGIN/END blocks up to 25 deep -- although it is unlikely you
  2558.     will ever need that much nesting.  Here is an example of code that uses
  2559.     nesting up to three deep:
  2560.     
  2561.     BEGIN datatype = "Dog"           <----------------------------------
  2562.       SET breed = $FLINE[1 10]                                         | First
  2563.       BEGIN breed = "Collie"         <-----------------------          | Level
  2564.         SET noise = "Woof"                                  | Second   | Block
  2565.         BEGIN name = "Spot"          <------ Third          | Level    |
  2566.           SET attitude = "Friendly"        | Level          | Block    |
  2567.         END                          <------ Block          |          |
  2568.       END                            <-----------------------          |
  2569.       BEGIN breed = "Other"          <----------------------- Another  |
  2570.         SET noise = "Arf"                                   | Second   |
  2571.         SET attitude = "Unknown"                            | Level    |
  2572.       END                            <----------------------- Block    |
  2573.     END                              <----------------------------------
  2574.     
  2575.     Once again, the indentation is for clarity only and does not affect the
  2576.     way the POM file runs.  However, you will find that it makes your POM
  2577.     file much easier to understand.
  2578.     
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.                                                                              38
  2585.                                   ----------------
  2586.                                   The CALL Command
  2587.                                   ----------------
  2588.     
  2589.     FORMAT:        CALL value1
  2590.     
  2591.     PURPOSE:       Executes a subroutine (see "The Code Command")
  2592.     
  2593.     PARAMETERS:    value1 is the name of the subroutine
  2594.     
  2595.     The basic concepts of the CALL and CODE commands are discussed in the
  2596.     section entitled "The Code Command".
  2597.     
  2598.     --------------
  2599.     Variable CALLs
  2600.     --------------
  2601.     
  2602.     value1 will usually be a literal (e.g. CALL "Output Field"). However, it can
  2603.     also be a variable.  For example:
  2604.     
  2605.     IF       $FLINE[1] = "0" THEN routine = "Handle Type 0" ELSE "Handle Type 1"
  2606.     CALL     routine
  2607.     
  2608.     This calls the subroutine "Handle Type 0" if the first character of $FLINE
  2609.     is "0".  Otherwise, it calls the subroutine "Handle Type 1".  An alternative
  2610.     to this approach is:
  2611.     
  2612.     BEGIN    $FLINE[1] = "0"
  2613.       (code to handle Type 1 records)
  2614.     ELSE
  2615.       (code to handle other types of records)
  2616.     END
  2617.     
  2618.     Both methods accomplish the same thing, so the one you choose is largely a
  2619.     matter of personal preference.  In general, however, you should use CALL and
  2620.     CODE only when the same code is required in several different places in the
  2621.     POM file.  There are some exceptions however, as described in the next
  2622.     section...
  2623.     
  2624.     -----------------------------
  2625.     Making Your Technique Obvious
  2626.     -----------------------------
  2627.     
  2628.     Consider this example:
  2629.     
  2630.     APPEND   routine "Type" $FLINE[1]
  2631.     CALL     routine
  2632.     
  2633.     You can use this method to call subroutines named "Type0", "Type1", "Type2"
  2634.     and so on, according to the first character of $FLINE.  This can make your
  2635.     POM file a lot easier to understand.
  2636.     
  2637.  
  2638.  
  2639.                                                                              39
  2640.     Additionally, you may sometimes want to break up large parsing jobs into
  2641.     distinct pieces.  Thus, the main part of your POM file might read as
  2642.     follows:
  2643.     
  2644.     CALL     "Break Up Fields"
  2645.     CALL     "Clean Up Data"
  2646.     CALL     "Send to Output"
  2647.     
  2648.     If each of these steps is quite long and involved, your POM file may be
  2649.     easier to read and understand by using CALL, as shown, to portray the basic
  2650.     steps.
  2651.     
  2652.     ------------------------------
  2653.     Avoiding Unknown Code Sections
  2654.     ------------------------------
  2655.     
  2656.     If you attempt to call a subroutine that does not exist, Parse-O-Matic will
  2657.     terminate with an error message, saying it can not find the CODE section.
  2658.     It is a good idea to check for this possibility, as in this example:
  2659.     
  2660.     LOG      "012345" ~ $FLINE[1] "Unknown record type: " $FLINE[1]
  2661.     HALT     "012345" ~ $FLINE[1] "Unknown record type -- see processing log"
  2662.     APPEND   routine "Type" $FLINE[1]
  2663.     CALL     routine
  2664.     
  2665.     This will provide a more meaningful error message if the first character
  2666.     of $FLINE is not one that you expected (zero through five, in the example
  2667.     given above).
  2668.     
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.                                                                              40
  2695.                                   ----------------
  2696.                                   The CODE Command
  2697.                                   ----------------
  2698.     
  2699.     FORMAT:        The format of a subroutine is as follows:
  2700.     
  2701.                    CODE value1
  2702.                    :
  2703.                    Code run when this subroutine is invoked by the CALL command
  2704.                    :
  2705.                    END
  2706.     
  2707.     PURPOSE:       Defines a subroutine
  2708.     
  2709.     PARAMETERS:    value1 is the name of the subroutine
  2710.     
  2711.     NOTES:         value1 can be up to 255 characters long and may contain any
  2712.                    characters (including spaces).  Case is not important, so
  2713.                    "Read New Data" is treated the same as "READ NEW DATA".
  2714.                    Leading and trailing spaces and tabs are ignored.
  2715.     
  2716.     Subroutines are useful when a POM file has to perform the same series of
  2717.     commands in several different circumstances.  Consider this POM file:
  2718.     
  2719.     SET      field = $FLINE[10 20]  <-- Get a field
  2720.     CALL     "Output Date Field"    <-- Run a subroutine
  2721.     SET      field = $FLINE[30 40]  <-- Get a field
  2722.     CALL     "Output Date Field"    <-- Run a subroutine
  2723.     CODE     "Output Date Field"    <-- Start of subroutine     <-+
  2724.       CHANGE   field " " "/"        <-- Correct date format       |
  2725.       CHANGE   field "\" "/"        <-- Correct date format       |
  2726.       CHANGE   field "-" "/"        <-- Correct date format       | Subroutine
  2727.       CVTCASE  field field          <-- Convert to uppercase      |
  2728.       OUTEND   |{field}             <-- Output the field          |
  2729.     END                             <-- End of subroutine       <-+
  2730.     
  2731.     In this example, the subroutine (named "Output Date Field") tidies up the
  2732.     data before sending it to the output file.  For example, if the date field
  2733.     is "10 31 98", it is converted to "10/31/98".
  2734.     
  2735.     As you can see, subroutines can reduce the number of lines in a POM file.
  2736.     Also, if you give your subroutines meaningful names, your POM file will be
  2737.     much easier to understand.
  2738.     
  2739.     Subroutines also make it easier to update a POM file.  For example, if you
  2740.     noticed that the date field is sometimes delimited with the "plus" symbol,
  2741.     you could simply add the line  CHANGE field "+" "/"  to the "Output Date
  2742.     Field" subroutine.  In other words, you would add a single line of code
  2743.     instead of several lines.
  2744.     
  2745.     Subroutines are ignored by Parse-O-Matic unless they are explicitly invoked
  2746.     by a CALL command.
  2747.     
  2748.  
  2749.                                                                              41
  2750.     --------------------------
  2751.     Performance Considerations
  2752.     --------------------------
  2753.     
  2754.     If you have a POM file with a lot of subroutines, you can improve its
  2755.     performance slightly by moving all the CODE sections to the end of the file,
  2756.     and placing a DONE command in front of them.  This saves Parse-O-Matic the
  2757.     trouble of reading through them each time it processes a line.
  2758.     
  2759.     -----------------------
  2760.     Nested Subroutine Calls
  2761.     -----------------------
  2762.     
  2763.     You can call a subroutine from within a subroutine.  For example:
  2764.     
  2765.     CODE     "Clean Up Date Field"
  2766.       CHANGE   field " " "/"
  2767.       CHANGE   field "\" "/"
  2768.       CHANGE   field "-" "/"
  2769.       CVTCASE  field field
  2770.     END
  2771.     CODE     "Output Date Field"
  2772.       CALL     "Clean Up Date Field"
  2773.       OUTEND   |{field}
  2774.     END
  2775.     
  2776.     The second subroutine ("Output Date Field") calls the first subroutine
  2777.     ("Clean Up Date Field").  This feature is useful if several subroutines
  2778.     require the same processing.
  2779.     
  2780.     You must be careful not to have circular references (a subroutine that calls
  2781.     a subroutine which in turn calls the first subroutine).  This will call
  2782.     Parse-O-Matic to fail.
  2783.     
  2784.     Subroutine calls can be nested up to 25 deep.  That is to say, a subroutine
  2785.     can call a second subroutine, which can call a third subroutine, and so on,
  2786.     all the way up the 24th subroutine calling the 25th subroutine.  It is,
  2787.     however, unlikely that you will ever nest subroutines more than two or three
  2788.     deep.
  2789.     
  2790.     ----------------------
  2791.     Variable Code Sections
  2792.     ----------------------
  2793.     
  2794.     You may be wondering if you can place a variable in the value1 position of
  2795.     the CODE command, just as you can have a variable CALL command.  While it is
  2796.     possible to do so (i.e. Parse-O-Matic will not fail), we do not officially
  2797.     support this usage, as we see no reason for it.  If you do find a reason for
  2798.     it, make sure that the variable is first converted to uppercase.
  2799.     
  2800.  
  2801.  
  2802.  
  2803.  
  2804.                                                                              42
  2805.     ---------------------------------
  2806.     A Note to Experienced Programmers
  2807.     ---------------------------------
  2808.     
  2809.     Experienced programmers of other languages (e.g. Pascal, C, Basic, etc.) may
  2810.     wonder if there is a way to pass one or more variables to a subroutine.
  2811.     Parse-O-Matic does not currently support traditional features such as
  2812.     functions, variable-passing or local variables. These features (and other
  2813.     niceties such as code libraries) may be added in a later release.
  2814.     Parse-O-Matic's design is guided primarily by customer demand.
  2815.     
  2816.                                   ----------------
  2817.                                   The ELSE Command
  2818.                                   ----------------
  2819.     
  2820.     FORMAT:        The format of a BEGIN/ELSE/END block is as follows:
  2821.     
  2822.                    BEGIN value1 [comparator] value2
  2823.                    :
  2824.                    Code that is run if the comparison is true
  2825.                    :
  2826.                    ELSE
  2827.                    :
  2828.                    Code that is run if the comparison is false
  2829.                    :
  2830.                    END
  2831.     
  2832.     PURPOSE:       The ELSE command tells Parse-O-Matic to execute the
  2833.                    following block of code (up until the END command) if the
  2834.                    corresponding BEGIN comparison is NOT true.
  2835.     
  2836.     NOTES:         The ELSE command is not the same as the ELSE used to pad the
  2837.                    IF statement (e.g. IF xyz = "3" THEN x = "Y" ELSE "N").  In
  2838.                    the IF command, ELSE makes the statement more clear, but it
  2839.                    can be omitted (e.g. IF $FLINE[1] "3" x "Y" "N").
  2840.     
  2841.     Here is an example of a BEGIN/ELSE/END block:
  2842.     
  2843.     BEGIN $FLINE[1 10] = "JOHN SMITH"
  2844.       SET x = "This is John"
  2845.     ELSE
  2846.       SET x = "This is not John"
  2847.     END
  2848.     
  2849.     If you are using several levels of nesting, it is a good idea to indent
  2850.     your code to show the relationship of the BEGIN, ELSE and END statements:
  2851.     
  2852.  
  2853.  
  2854.  
  2855.  
  2856.  
  2857.  
  2858.  
  2859.                                                                              43
  2860.     BEGIN datatype = "Dog"           <----------------------------------
  2861.       SET breed = $FLINE[1 10]                                         | First
  2862.       BEGIN breed = "Collie"         <-----------------------          | Level
  2863.         SET noise = "Woof"                                  | Second   | Block
  2864.         BEGIN name = "Spot"          <------ Third          | Level    |
  2865.           SET attitude = "Friendly"        | Level          | Block    |
  2866.         END                          <------ Block          |          |
  2867.       ELSE                                                  |          |
  2868.         SET noise = "Arf"                                   |          |
  2869.         SET attitude = "Unknown"                            |          |
  2870.       END                            <-----------------------          |
  2871.     END                              <----------------------------------
  2872.     
  2873.     The ELSE is at "Level 2".  This is because there are three BEGINs ahead of
  2874.     it, but only one END (3 - 1 = 2).
  2875.     
  2876.                                   ---------------
  2877.                                   The END Command
  2878.                                   ---------------
  2879.     
  2880.     FORMAT:        END
  2881.     
  2882.     PURPOSE:       Marks the end of a BEGIN, PROLOGUE or EPILOGUE code block.
  2883.     
  2884.     The END command marks the end of a "code block".  A code block is a series
  2885.     of lines in a POM file that may be run if the conditions are right.
  2886.     
  2887.     For a more detailed discussion of the END command, see the following
  2888.     sections:
  2889.     
  2890.     - "The Begin Command"
  2891.     
  2892.     - "The Prologue Command"
  2893.     
  2894.     - "The Epilogue Command"
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.                                                                              44
  2915.                                  -----------------
  2916.                                  The AGAIN Command
  2917.                                  -----------------
  2918.     
  2919.     FORMAT #1:     BEGIN [value1 [comparator] value2]
  2920.                    :
  2921.                    Code executed if the BEGIN comparison is true or omitted
  2922.                    :
  2923.                    AGAIN [value1 [comparator] value2]
  2924.     
  2925.     FORMAT #2:     BEGIN value1 [comparator] value2
  2926.                    :
  2927.                    Code executed if the BEGIN comparison is true
  2928.                    :
  2929.                    ELSE
  2930.                    :
  2931.                    Code executed if the BEGIN comparison is false
  2932.                    :
  2933.                    AGAIN [value1 [comparator] value2]
  2934.     
  2935.     PURPOSE:       Controls the repetition of a BEGIN block.
  2936.     
  2937.     NOTES:         For an explanation of comparators, see "Using Comparators".
  2938.     
  2939.     SEE ALSO:      "The ReadNext Command", "The Begin Command", "The Else
  2940.                    Command" and "Uninitialized and Persistent Variables"
  2941.     
  2942.     DEFAULTS:      If the comparison part of the AGAIN command is omitted:
  2943.                    - AGAIN repeats if the BEGIN comparison was true or omitted
  2944.                    - AGAIN does not repeat if the BEGIN comparison was false
  2945.     
  2946.     ADVISORY:      If you are familiar with other computer languages, you may
  2947.                    be tempted to use AGAIN to create loops when none are
  2948.                    required.  Remember that a POM file is repeated (i.e.
  2949.                    looped) each time a record or line is read from the input
  2950.                    file.  The AGAIN command is most appropriate when you have
  2951.                    input records with a variable number of items.
  2952.     
  2953.     The AGAIN command allows you to implement "loops".  A loop is a section of
  2954.     code that can be repeated one or more times.
  2955.     
  2956.     AGAIN returns to the corresponding BEGIN if the comparison is true, or if
  2957.     it is omitted.  Since the BEGIN can also have a comparison, and can be used
  2958.     with the ELSE command, this allows many variations:
  2959.     
  2960.     COMMAND ARRANGEMENT             EFFECT
  2961.     ------------------------------  -----------------------------------------
  2962.     BEGIN               AGAIN       Loops forever
  2963.     BEGIN comp          AGAIN       Loops until the BEGIN comparison is false
  2964.     BEGIN               AGAIN comp  Loops until the AGAIN comparison is false
  2965.     BEGIN comp          AGAIN comp  Loops until either comparison is false
  2966.     BEGIN comp   ELSE   AGAIN comp  Loops until either comparison is false
  2967.     BEGIN comp   ELSE   AGAIN       Loops until the BEGIN comparison is false
  2968.  
  2969.                                                                              45
  2970.     In the last two examples, the ELSE code is run when the BEGIN comparison is
  2971.     false, then processing continues on the POM line after the AGAIN command.
  2972.     When a BEGIN comparison is false, the comparison (if any) of the AGAIN
  2973.     command is not evaluated.
  2974.     
  2975.     To put it another way:  the AGAIN comparison is considered only if the
  2976.     BEGIN comparison is true or omitted.
  2977.     
  2978.     ------------------------------------
  2979.     Using AGAIN for Variable-Length Data
  2980.     ------------------------------------
  2981.     
  2982.     Let us say you have a text file that contains the names of people belonging
  2983.     to various clubs.  The file lists the name of the club, then the number of
  2984.     people in each club, and then the names:
  2985.     
  2986.     Chess Club
  2987.     3
  2988.     John Smith
  2989.     Mary Jones
  2990.     Fred Williams
  2991.     Hopscotch Club
  2992.     0
  2993.     Tennis Club
  2994.     2
  2995.     Jack Martin
  2996.     Debbie Harris
  2997.     
  2998.     You could process this input file with the following POM file:
  2999.     
  3000.     PAD      $FLINE "R" " " "17"      <-- Pad the club name out with spaces
  3001.     OUT      |{$FLINE}                <-- Send the club name to the output file
  3002.     READNEXT                          <-- Get the number of members
  3003.     SET      members  = $FLINE        <-- Remember this number
  3004.     BEGIN    members  = "0"           <-- Check if we have any members
  3005.       OUT      |(None)                <-- Report if we have no members
  3006.     ELSE                              <-- If we have members, do the next part
  3007.       SET      count    = "0"         <-- Initialize a counter
  3008.       BEGIN                           <-- Start the loop
  3009.         READNEXT                      <-- Get the person's name
  3010.         SET    count = count+         <-- Count this person
  3011.         OUT    |{$FLINE}              <-- Send the name to the file
  3012.         OUT    count #< members |/    <-- Add a separator if not the last name
  3013.       AGAIN    count #< members       <-- Go back if we have more members
  3014.     END                               <-- Corresponds to the first BEGIN
  3015.     OUTEND  |                         <-- Start a new line after each club
  3016.     
  3017.     This POM file would generate the following output:
  3018.     
  3019.     Chess Club       John Smith/Mary Jones/Fred Williams
  3020.     Hopscotch Club   (None)
  3021.     Tennis Club      Jack Martin/Debbie Harris
  3022.     
  3023.  
  3024.                                                                              46
  3025.     ------------------------------
  3026.     Pointless Command Combinations
  3027.     ------------------------------
  3028.     
  3029.     Some combinations of BEGIN, ELSE and AGAIN are pointless.  The following
  3030.     command arrangements contain code that is never run:
  3031.     
  3032.     COMMAND ARRANGEMENT             NOTE
  3033.     ------------------------------  ------------------------------------------
  3034.     BEGIN        ELSE   AGAIN comp  The ELSE portion is never executed
  3035.     BEGIN        ELSE   AGAIN       Loops forever; the ELSE portion never runs
  3036.     
  3037.     --------
  3038.     Examples
  3039.     --------
  3040.     
  3041.     Either of these two POM files will read a text file and ignore any lines
  3042.     that contain the words "COW":
  3043.     
  3044.     Using the AGAIN Command       Using the IGNORE Command
  3045.     -----------------------       ------------------------
  3046.     BEGIN $FLINE ^ "COW"          IGNORE $FLINE ^ "COW"
  3047.       READNEXT                    OUTEND |{$FLINE}
  3048.     AGAIN
  3049.     OUTEND |{$FLINE}
  3050.     
  3051.     The shorter POM file is more efficient, but the results would be the
  3052.     roughly the same for both.  Remember that a POM file is processed each
  3053.     time Parse-O-Matic reads an input record (or line), so the second version
  3054.     is, in effect, looping as many times as there are records in the file.
  3055.     
  3056.     The following POM file will read one line from a file, then send the string
  3057.     [6]123[7]123[6]123[7]123 to the output file:
  3058.     
  3059.     SET      z = "0"
  3060.     BEGIN                      <-----------------------------
  3061.       SET      y = "5"                                      | First
  3062.       BEGIN    y <> "7"        <------------------          | Level
  3063.         SET      x = "0"                         | Second   | (Outermost)
  3064.         SET      y = y+                          | Level    | Loop
  3065.         APPEND   s s "[" y "]"                   | Loop     |
  3066.         BEGIN    x <> "3"      <--------         |          |
  3067.           SET      x = x+              | Third   |          |
  3068.           APPEND   s s x               | Level   |          |
  3069.         AGAIN                  <--------         |          |
  3070.       AGAIN                    <------------------          |
  3071.       SET     z = z+                                        |
  3072.     AGAIN   z <> "2"           <-----------------------------
  3073.     OUTEND  |{s}
  3074.     NEXTFILE
  3075.     
  3076.  
  3077.  
  3078.  
  3079.                                                                              47
  3080.     The third level (innermost) loop ... generates 123
  3081.     The second level (middle) loop ..... generates [6]123[7]123
  3082.     The first level (outermost) loop ... generates [6]123[7]123[6]123[7]123
  3083.     
  3084.     The following POM file will read one line from a file, then send the
  3085.     string "XXXY" to the output file:
  3086.     
  3087.     SET      z = "0"           <-- Initialize a counter
  3088.     SET      s = ""            <-- Initialize the string we will output
  3089.     BEGIN    z < "3"           <-- Check if the counter has reached "3"
  3090.       SET      z = z+          <-- Add one to the counter
  3091.       APPEND   s s "X"         <-- Add an "X" to the end of the output string
  3092.     ELSE                       /__ The ELSE section is run when
  3093.       APPEND   s s "Y"         \   the BEGIN comparison is false
  3094.     AGAIN                      <-- Go back to the BEGIN
  3095.     OUTEND   |{s}              <-- Continue here after the ELSE portion
  3096.     NEXTFILE                   <-- Stop reading the input file
  3097.     
  3098.                                   ----------------
  3099.                                   The DONE Command
  3100.                                   ----------------
  3101.     
  3102.     FORMAT:        DONE [value1 [comparator] value2]
  3103.     
  3104.     PURPOSE:       The DONE command will discontinue processing the POM file
  3105.                    and proceed to the next input line, whereupon the POM file
  3106.                    will restart at the top.
  3107.     
  3108.     NOTES:         For an explanation of comparators, see "Using Comparators".
  3109.                    In the following explanation, we will demonstrate the
  3110.                    command using only the "literally identical" ("=")
  3111.                    comparator.
  3112.     
  3113.     ALTERNATIVES:  The NEXTFILE, IGNORE and ACCEPT commands
  3114.     
  3115.     The DONE command is most useful when you have a long series of BEGIN/END
  3116.     blocks which make a related comparison.  For example:
  3117.     
  3118.  
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.                                                                              48
  3135.     SET   salesrep = $FLINE[11 50]
  3136.     SET   region   = $FLINE[ 1  2]
  3137.     BEGIN region = "US"
  3138.       OUTEND |Sales representative for U.S.A.: {salesrep}
  3139.       DONE
  3140.     END
  3141.     BEGIN region = "CN"
  3142.       OUTEND |Sales representative for Canada: {salesrep}
  3143.       DONE
  3144.     END
  3145.     BEGIN region = "EU"
  3146.       OUTEND |Sales representative for Europe: {salesrep}
  3147.       DONE
  3148.     END
  3149.     :
  3150.     etc.
  3151.     
  3152.     As you can see, if one of the BEGIN comparisons is true, all of the
  3153.     following ones will inevitably be false.  Rather than processing all the
  3154.     others, you can use the DONE command to bail out and get ready for the
  3155.     next input line.
  3156.     
  3157.     The DONE command provides two benefits:
  3158.     
  3159.     - It can speed up processing slightly
  3160.     - It makes full traces easier to understand
  3161.     
  3162.     For an explanation of traces, see the section entitled "Tracing".
  3163.     
  3164.     Unless you use a comparison (explained later), the DONE command is useful
  3165.     only inside BEGIN/ELSE/END blocks.  If you write a POM file like this:
  3166.     
  3167.     SET custnum  = $FLINE[ 1 10]
  3168.     SET custname = $FLINE[11 50]
  3169.     DONE
  3170.     OUTEND |{custname} {custnum}
  3171.     
  3172.     then the OUTEND statement will NEVER be reached.
  3173.     
  3174.     Here is how you specify a comparison for the DONE command:
  3175.     
  3176.     DONE $FLINE = "End of Data"
  3177.     
  3178.     This discontinues the POM file, and proceeds to the next input line, if the
  3179.     current input line ($FLINE) is "End of Data".
  3180.     
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.                                                                              49
  3190.                                 --------------------
  3191.                                 The NEXTFILE Command
  3192.                                 --------------------
  3193.     
  3194.     FORMAT:        NEXTFILE [value [comparator] value]
  3195.     
  3196.     PURPOSE:       NEXTFILE discontinues processing the current input file and
  3197.                    proceeds to the next one, restarting the POM file from the
  3198.                    top.
  3199.     
  3200.     NOTES:         For an explanation of comparators, see "Using Comparators".
  3201.                    In the following explanation, we will demonstrate the
  3202.                    command using only the "literally identical" ("=")
  3203.                    comparator.
  3204.     
  3205.     ALTERNATIVES:  The HALT command
  3206.     
  3207.     The NEXTFILE command is useful when you process multiple input files (see
  3208.     "POM and Wildcards").  Here is an example, which we will call TEST.POM:
  3209.     
  3210.     BEGIN $FLINE = "End of Data"
  3211.       OUTEND |{numlines} lines of data printed
  3212.       SET    numlines = ""
  3213.       NEXTFILE
  3214.     END
  3215.     SET    numlines = numlines+
  3216.     OUTEND |{$FLINE}
  3217.     
  3218.     Let's say you have three text files: DATA1.XYZ, DATA2.XYZ and DATA3.XYZ.
  3219.     The last line of each file says "End of Data".  You could copy all three
  3220.     files to the file OUTPUT.TXT with this command:
  3221.     
  3222.     POM TEST.POM DATA?.XYZ OUTPUT.TXT
  3223.     
  3224.     This would copy the data from each file, but when it gets to the line
  3225.     reading "End of Data", it records the number of lines of data that were
  3226.     printed.  Any lines after the "End of Data" line are skipped, because of
  3227.     the NEXTFILE command.
  3228.     
  3229.     The NEXTFILE command can specify a comparison.  Here is an example:
  3230.     
  3231.     NEXTFILE $FLINE = "End of Data"
  3232.     OUTEND |{$FLINE}
  3233.     
  3234.     Assuming the same input files (DATA1.XYZ etc.), and using the same POM
  3235.     command as last time, this POM file would simply copy up to (but not
  3236.     including" the line that reads "End of Data" in each input file.
  3237.     
  3238.  
  3239.  
  3240.  
  3241.  
  3242.  
  3243.  
  3244.                                                                              50
  3245.                                   ----------------
  3246.                                   The HALT Command
  3247.                                   ----------------
  3248.     
  3249.     FORMAT:        HALT value1 comparison value2 value3 [value4]
  3250.     
  3251.     PURPOSE:       The HALT command will terminate Parse-O-Matic processing if
  3252.                    the comparison is true.
  3253.     
  3254.     PARAMETERS:    value1 is any value
  3255.                    value2 is any value
  3256.                    value3 is the message to be displayed
  3257.                    value4 is the optional error level (between 100 to 199)
  3258.     
  3259.     NUMERICS:      Tabs, spaces and commas are stripped from value4
  3260.     
  3261.     ALTERNATIVES:  The NEXTFILE command
  3262.     
  3263.     SEE ALSO:      "The MsgWait Command"
  3264.     
  3265.     Here is an example of the HALT command:
  3266.     
  3267.     HALT sales = "0" "Zero sales!"
  3268.     
  3269.     If the variable named sales is "0", Parse-O-Matic will display an error
  3270.     box reading "Zero sales!" and terminate after you have pressed a key.  A
  3271.     copy of the message is also placed in the processing log POMLOG.TXT (see
  3272.     "Logging").
  3273.     
  3274.     When a HALT condition occurs, Parse-O-Matic terminates with a DOS error
  3275.     level of 100.  You can specify a different value, using value4.  This is
  3276.     useful if you are calling Parse-O-Matic from a batch file or application
  3277.     program and want to handle different errors in different ways.
  3278.     
  3279.     You can set value4 to any number between 100 and 199.  Consider these
  3280.     examples:
  3281.     
  3282.     HALT sales    = "0" "Zero sales"     "150"
  3283.     HALT sales[1] = "-" "Negative sales" "160"
  3284.     
  3285.     This terminates Parse-O-Matic with an error level of 150 if sales are zero.
  3286.     If the first character of sales is a minus sign, Parse-O-Matic terminates
  3287.     with an error level of 160.
  3288.     
  3289.     When coding batch files, remember that the IF ERRORLEVEL command is
  3290.     considered "True" if the error is the specified value or higher.  This
  3291.     means you should always test the higher value first.  See your operating
  3292.     system manual for details.
  3293.     
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.                                                                              51
  3300.                                 --------------------
  3301.                                 The PROLOGUE Command
  3302.                                 --------------------
  3303.     
  3304.     FORMAT:        The format for PROLOGUE (used with the END command) is:
  3305.     
  3306.                    PROLOGUE
  3307.                    :
  3308.                    Dependant code
  3309.                    :
  3310.                    END
  3311.     
  3312.     PURPOSE:       PROLOGUE defines dependant code which is run before the
  3313.                    first line of the input file is read.
  3314.     
  3315.     SEE ALSO:      "The Epilogue Command"
  3316.     
  3317.     PROLOGUE can be used to set up some variables, or set up a heading --
  3318.     anything you only want to do once per input file, at the very start.
  3319.     
  3320.     Here is an example of the PROLOGUE command:
  3321.     
  3322.     PROLOGUE
  3323.       SET both  = "B"
  3324.       SET space = " "
  3325.     END
  3326.     SET    firstname = $FLINE[ 1 10]
  3327.     SET    lastname  = $FLINE[15 25]
  3328.     TRIM   firstname both space
  3329.     TRIM   lastname  both space
  3330.     OUTEND |{firstname} {lastname}
  3331.     
  3332.     When the input file is first opened, the PROLOGUE section sets the
  3333.     variables "both" and "space".  Once they're set, you don't have to change
  3334.     them (since you are just using them to make the code easier to read).  Thus,
  3335.     it makes sense to set them only at the beginning of processing and not
  3336.     bother setting them each time the POM file is executed (i.e. each time an
  3337.     input line is read).
  3338.     
  3339.     If you are working with multiple files (see "POM and Wildcards"), the
  3340.     PROLOGUE is run for each input file.  If you want to run some code for
  3341.     the first file only, you can set a "flag", as in this example:
  3342.     
  3343.     BEGIN firstfile = ""
  3344.       SET firstfile = "N"
  3345.       OUTEND |First file only
  3346.     ELSE
  3347.       OUTEND |Subsequent files
  3348.     END
  3349.     NEXTFILE
  3350.     
  3351.     If you run this POM file on several files at once, using wildcards, the
  3352.     first line of the output file will contain the words "First file only",
  3353.  
  3354.                                                                              52
  3355.     since the variable "firstfile" has not yet been assigned a value.  On
  3356.     subsequent files, the variable will have the value "N", so the following
  3357.     lines of the output file will read "Subsequent files".
  3358.     
  3359.                                 --------------------
  3360.                                 The EPILOGUE Command
  3361.                                 --------------------
  3362.     
  3363.     FORMAT:        The format for EPILOGUE (used with the END command) is:
  3364.     
  3365.                    EPILOGUE
  3366.                    :
  3367.                    Dependant code
  3368.                    :
  3369.                    END
  3370.     
  3371.     PURPOSE:       EPILOGUE defines dependant code which is run after the last
  3372.                    line of the input file is read and the POM file is executed
  3373.                    to process it.  In other words, once all the input data is
  3374.                    finished, the POM file runs one last time -- but only the
  3375.                    code in the EPILOGUE section.
  3376.     
  3377.     SEE ALSO:      "The Prologue Command"
  3378.     
  3379.     You can use EPILOGUE to output final results.  Let's say your input file
  3380.     looks like this:
  3381.     
  3382.     DESCRIPTION      UNITS SOLD    UNIT PRICE
  3383.     Wildebeest food         325    $     9.99
  3384.     Horse cologne            13    $     3.25
  3385.     Moose alarm             210    $     5.95
  3386.     :                :        :     :       :    (Column positions)
  3387.     1               18       27    33      41
  3388.     
  3389.     You can find out the total number of units sold (of all types) with the
  3390.     following POM file:
  3391.     
  3392.     IGNORE $FLINE[1 7] = "DESCRIP"
  3393.     CALC   units = units "+" $FLINE[18 27]
  3394.     EPILOGUE
  3395.       OUTEND |Total units sold = {units}
  3396.     END
  3397.     
  3398.     This POM file adds up the number of units sold.  The only output is the
  3399.     single line generated by the OUTEND in the EPILOGUE.
  3400.     
  3401.     If you are processing multiple files (see "POM and Wildcards"), the
  3402.     EPILOGUE is run after each input file is finished.
  3403.     
  3404.     
  3405.     
  3406.  
  3407.  
  3408.  
  3409.                                                                              53
  3410.     ============================================================================
  3411.                                  VARIABLE MODIFIERS
  3412.     ============================================================================
  3413.     
  3414.                                   ----------------
  3415.                                   The TRIM Command
  3416.                                   ----------------
  3417.     
  3418.     FORMAT:        TRIM var1 value1 value2
  3419.     
  3420.     PURPOSE:       TRIM removes the character in value2 from var1.
  3421.     
  3422.     PARAMETERS:    var1   is the variable being set
  3423.                    value1 is "A" = All; "B" = Both ends;
  3424.                              "L" = Left side only; "R" = Right side only;
  3425.                              "M" = Multiples
  3426.                    value2 is the character to be removed.
  3427.     
  3428.     ALTERNATIVES:  The CHANGE command
  3429.     
  3430.     The TRIM command gets rid of unwanted characters in a variable.  It is
  3431.     typically used to remove blanks from either side of text, or leading zeros
  3432.     from numeric data.
  3433.     
  3434.     For example, to remove commas and the leading dollar sign from a number:
  3435.     
  3436.     SET  PRICE = $FLINE[20 26]      <-- Get the variable from the input file
  3437.     TRIM PRICE "A" ","              <-- Trim All
  3438.     TRIM PRICE "L" "$"              <-- Trim Left
  3439.     
  3440.     Here is how it works:
  3441.     
  3442.     If the input contains the string:   "$25,783"
  3443.     The first TRIM changes it to:       "$25783"
  3444.     The second TRIM changes it to:      "25783"
  3445.     
  3446.     You can also squeeze out multiple occurences of a given character.  For
  3447.     example, to remove multiple spaces from a variable named xyz, use this
  3448.     command:
  3449.     
  3450.     TRIM xyz "M" " "
  3451.     
  3452.     If xyz has the value "  A  B C  ", the command shown above changes it to
  3453.     " A B C ".  You can then get rid of the spaces at both ends with this
  3454.     command:
  3455.     
  3456.     TRIM xyz "B" " "
  3457.     
  3458.     This changes the xyz variable to "A B C".
  3459.     
  3460.  
  3461.  
  3462.  
  3463.  
  3464.                                                                              54
  3465.                                   ---------------
  3466.                                   The PAD Command
  3467.                                   ---------------
  3468.     
  3469.     FORMAT:        PAD var1 value1 value2 value3
  3470.                        :    :       :     :
  3471.     MEANING:       Variable Control Char  Number
  3472.     
  3473.     PURPOSE:       PAD makes var1 a specified length, padded with a
  3474.                    specified character.
  3475.     
  3476.     PARAMETERS:    var1   is the variable being set
  3477.                    value1 is "L", "R", or "C" (Left, Right or Center)
  3478.                    value2 is the character used to pad the string
  3479.                    value3 is the desired string length
  3480.     
  3481.     NUMERICS:      Tabs, spaces and commas are stripped from value3
  3482.     
  3483.     ALTERNATIVES:  The CHANGE command
  3484.     
  3485.     Here is an example of the PAD command.  If the variable ABC is already set
  3486.     to "1234" ...
  3487.     
  3488.     PAD ABC "L" "0" "7"   left-pads it 7 characters wide with zeros ("0001234")
  3489.     PAD ABC "R" " " "5"   right-pads it 5 characters wide with spaces ("1234 ")
  3490.     PAD ABC "C" "*" "8"   centers it, 8 wide, with asterisks ("**1234**")
  3491.     
  3492.     If the length is less than the length of the string, it is unchanged.  For
  3493.     example, if you set variable XYZ to "PINNACLE", then
  3494.     
  3495.     PAD XYZ "R" " " "3"
  3496.     
  3497.     leaves the string as-is ("PINNACLE").
  3498.     
  3499.     Thus, PAD can not be used to shorten a string.  If it is your intention to
  3500.     make XYZ 3 letters long, you can use the SET command:
  3501.     
  3502.     SET XYZ = XYZ[1 3]
  3503.     
  3504.  
  3505.  
  3506.  
  3507.  
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.                                                                              55
  3520.                                  ------------------
  3521.                                  The CHANGE Command
  3522.                                  ------------------
  3523.     
  3524.     FORMAT:        CHANGE var1 value1 value2
  3525.     
  3526.     PURPOSE:       The CHANGE command replaces ALL occurrences of value1
  3527.                    with value2.
  3528.     
  3529.     ALTERNATIVES:  The TRIM command.  (The CHANGE command is more powerful than
  3530.                    TRIM, but is not as efficient).
  3531.     
  3532.     Here is an example of the CHANGE command in action:
  3533.     
  3534.     SET    DATE = $FLINE[31 38]
  3535.     CHANGE DATE "/" "--"
  3536.     
  3537.     If the SET command assigns DATE the value:    "93/10/15"
  3538.     Then the CHANGE command converts it to:       "93--10--15"
  3539.     
  3540.                                 -------------------
  3541.                                 The CVTCASE Command
  3542.                                 -------------------
  3543.     
  3544.     FORMAT:        CVTCASE  var1 value1 [value2]
  3545.     
  3546.     PURPOSE:       CVTCASE converts a value to uppercase or lowercase.
  3547.     
  3548.     PARAMETERS:    var1   is the variable being set
  3549.                    value1 is the value being converted
  3550.                    value2 is the optional control setting
  3551.     
  3552.     DEFAULTS:      value2 = "UI"
  3553.     
  3554.     ALTERNATIVES:  The PROPER or REMAP commands; $FLUPC
  3555.     
  3556.     CVTCASE converts value1 to uppercase or lowercase and places the result in
  3557.     var1.  Here are some examples:
  3558.     
  3559.          COMMAND                      DESCRIPTION
  3560.          ---------------------------  --------------------------------
  3561.          CVTCASE xyz "Test Case" "U"  Sets variable xyz to "TEST CASE"
  3562.          CVTCASE xyz "Test Case" "L"  Sets variable xyz to "test case"
  3563.          CVTCASE xyz "Test Case"      Sets variable xyz to "TEST CASE"
  3564.     
  3565.     In the last example, the optional control parameter (value2) was omitted.
  3566.     In such case, CVTCASE will convert the value to uppercase.
  3567.     
  3568.  
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.                                                                              56
  3575.     ----------------
  3576.     Control Settings
  3577.     ----------------
  3578.     
  3579.     The control setting (value2) can be one or two characters long, or it can
  3580.     be omitted (in which case it is assumed to be "UI").  Here are the
  3581.     available settings for value2:
  3582.     
  3583.                     SETTING  CONVERT TO  CHARACTER SET
  3584.                     -------  ----------  ------------------
  3585.                     "L"      Lowercase   IBM Extended ASCII
  3586.                     "LI"     Lowercase   IBM Extended ASCII
  3587.                     "L7"     Lowercase   7-bit ASCII
  3588.                     "U"      Uppercase   IBM Extended ASCII
  3589.                     "UI"     Uppercase   IBM Extended ASCII
  3590.                     "U7"     Uppercase   7-bit ASCII
  3591.     
  3592.     The IBM Extended ASCII character set defines diacritical (accented)
  3593.     characters such as "U Umlaut" and "C Cedille"; these are located in the
  3594.     ASCII table above value 127.  It is the standard character set used by
  3595.     MS-DOS and PC-DOS.
  3596.     
  3597.     The 7-bit ASCII character set is concerned only with the characters in the
  3598.     original definition of ASCII (American Standard Code for Information
  3599.     Interchange), which does not support diacritical characters.  As such,
  3600.     uppercasing and lowercasing affect only alphabetic characters ("A" to "Z",
  3601.     and "a" to "z").  This character set is used by many mini-computers, and
  3602.     is the standard character set of the Unix operating system.
  3603.     
  3604.     The eighth bit is not ignored if you use CVTCASE with the 7-bit ASCII
  3605.     character set.  If you wish to set the eighth bit to zero (perhaps because
  3606.     it is a parity bit), you should use the REMAP command.
  3607.     
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.                                                                              57
  3630.                                  ------------------
  3631.                                  The PROPER Command
  3632.                                  ------------------
  3633.     
  3634.     FORMAT:        PROPER var1 [value1 [value2]]
  3635.     
  3636.     PURPOSE:       The PROPER command converts uppercase text (LIKE THIS) to
  3637.                    mixed-case text (Like This).
  3638.     
  3639.     PARAMETERS:    var1   is the variable being set
  3640.                    value1 is the methods setting
  3641.                    value2 is the name of the Properization Exception File
  3642.     
  3643.     DEFAULTS:      value1 = "IW"
  3644.     
  3645.     ALTERNATIVES:  The CHANGE command; $FLUPC (uppercase version of $FLINE)
  3646.     
  3647.     The PROPER command is useful when you have a list of names of people and
  3648.     addresses.  You can also use PROPER to change text that has been typed in
  3649.     uppercase into normal text, with capital letters at the beginning of
  3650.     sentences.
  3651.     
  3652.     The simplest way to convert a variable is as follows:
  3653.     
  3654.     PROPER CustName
  3655.     
  3656.     If CustName contains "JOHN SMITH", it will be changed to "John Smith".
  3657.     
  3658.     The conversion routine is fairly intelligent.  For example, if it is
  3659.     converting the words "JAGUAR XJS", it can tell that XJS is not a word
  3660.     (since it does not contain any vowels) and so the the end result will
  3661.     be "Jaguar XJS".  Other "strange-looking" items such as serial numbers
  3662.     can often be recognized by the PROPER command, and left untouched.
  3663.     
  3664.     Nevertheless, it is impossible to handle all situations, so the PROPER
  3665.     command supports a "Properization Exceptions File" (known as a PEF file).
  3666.     A PEF file lists unusual combinations of letters (typically abbreviations,
  3667.     such as Dr.).  The Parse-O-Matic package includes a file named GENERIC.PEF,
  3668.     which you may find helpful.  You can view it with the SEE program provided
  3669.     with Parse-O-Matic.
  3670.     
  3671.     A PEF file is prepared with a text editor and contains one "exception" per
  3672.     line.  Null or blank lines, or lines that start with a semicolon, are
  3673.     ignored.  The longest word that can be specified is 255 characters.
  3674.     Spaces are permitted, but leading and trailing spaces and tabs are ignored.
  3675.     
  3676.     To use the PEF file in your PROPER command, place the file name after the
  3677.     variable name and method setting.  For example:
  3678.     
  3679.     PROPER CustName "W" "GENERIC.PEF"
  3680.     
  3681.     The "W" is the method setting (explained later).  "GENERIC.PEF" is the name
  3682.     of the PEF file.  When Parse-O-Matic looks for the PEF file, it looks for
  3683.  
  3684.                                                                              58
  3685.     it in the current directory unless an explicit path is specified, then
  3686.     searches elsewhere, if necessary.  (For details, see the section entitled
  3687.     "How Parse-O-Matic Searches for a File".)
  3688.     
  3689.     If it can not find it there, it looks in the
  3690.     directory where POM.EXE is located.  You can, if you wish, specify a
  3691.     complete path to the file, as in this example:
  3692.     
  3693.     PROPER Address "W" "C:\MYFILES\MYPEF.XYZ"
  3694.     
  3695.     If you don't need an exceptions file, you should not use it, since it slows
  3696.     down processing somewhat.  Needless to say, the more items you have in the
  3697.     PEF file, the more it slows down processing.
  3698.     
  3699.     The method setting allows you to specify what PROPER does.  There are
  3700.     several kinds of controls, as follows:
  3701.     
  3702.           METHOD   DESCRIPTION
  3703.           ------   -----------
  3704.             I      Intelligent determination of non-words
  3705.             S      Upcase the first character of each sentence
  3706.             U      Upcase the first alphanumeric character of the line
  3707.             W      Upcase the first letter of each word
  3708.     
  3709.     The default method setting is "IW", so if you omit the method setting, or
  3710.     specify a null setting (e.g. PROPER CustName "" "XYZ.PEF"), PROPER will
  3711.     upcase non-words, and the first letter of each word.
  3712.     
  3713.     NOTE:  If you specify a PEF file, you must also specify a method setting,
  3714.     even if it is null.  The line PROPER x "GENERIC.PEF" would not be understood
  3715.     by Parse-O-Matic.  The correct format would be:  PROPER x "" "GENERIC.PEF"
  3716.     
  3717.     The examples provided with Parse-O-Matic demonstrate some ways you can use
  3718.     the PROPER command.  To see the examples, enter START at the DOS prompt,
  3719.     or run START.BAT from Windows or OS/2, then select TUTORIAL.
  3720.     
  3721.  
  3722.  
  3723.  
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.                                                                              59
  3740.                                  ------------------
  3741.                                  The INSERT Command
  3742.                                  ------------------
  3743.     
  3744.     FORMAT:        INSERT var1 value1 value2
  3745.     
  3746.     PURPOSE:       The INSERT command inserts text on the left or right of
  3747.                    var1, or at a "found text" position.
  3748.     
  3749.     PARAMETERS:    var1   is the variable being set
  3750.                    value1 is "L" or "R" (Left or Right) or a find-string
  3751.                           (e.g.  "<HELLO")
  3752.                    value2 is the value to be inserted
  3753.     
  3754.     ALTERNATIVES:  The APPEND and CHANGE commands
  3755.     
  3756.     For example, if the variable ABC is set to "Parse-O-Matic", then
  3757.     
  3758.     INSERT ABC "L" "Register "    sets ABC to "Register Parse-O-Matic"
  3759.     INSERT ABC "R" " is super"    sets ABC to "Parse-O-Matic is super"
  3760.     
  3761.     You can use a find-string to insert text either before or after the first
  3762.     occurrence of the text you specify.  For example, if the variable xyz is
  3763.     set to "One a day", then
  3764.     
  3765.     INSERT xyz "<e"    "c"        sets xyz to "Once a day"
  3766.     INSERT xyz ">One " "hour "    sets xyz to "One hour a day"
  3767.     
  3768.     The < prefix means "insert value1 before the found text".  The > prefix
  3769.     means "insert value1 after the found text".
  3770.     
  3771.     If the find-string is not found, nothing is done.
  3772.     
  3773.     NOTE:  Prior to version 3.40 of Parse-O-Matic, the "insert before" opera-
  3774.            tion was denoted by the @ prefix rather than the < prefix.  This
  3775.            still works, so you do not have to change your POM files.
  3776.     
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.                                                                              60
  3795.                                  ------------------
  3796.                                  The APPEND Command
  3797.                                  ------------------
  3798.     
  3799.     FORMAT:        APPEND var1 value1 value2 [value3 [value4]]
  3800.     
  3801.     PURPOSE:       The APPEND command concatenates (adds together) two or more
  3802.                    values and places the result in var1.
  3803.     
  3804.     NOTES:         No variable can hold more than 255 characters.
  3805.     
  3806.     ALTERNATIVES:  The INSERT command
  3807.     
  3808.     Here is an example of the APPEND command:
  3809.     
  3810.     APPEND xyz "AB" "CD" "EF" "GHIJ"
  3811.     
  3812.     This command sets the variable xyz to "ABCDEFGHIJ".
  3813.     
  3814.     The third and fourth values (value3 and value4 in the FORMAT shown above)
  3815.     are optional.  Thus, you can use APPEND with only two values.  For example:
  3816.     
  3817.     SET    x1 = "AB"
  3818.     SET    x2 = "CD"
  3819.     APPEND x3 x1 x2
  3820.     
  3821.     This sets the variable x3 to "ABCD".  You can concatenate a maximum of four
  3822.     values with a single APPEND command.  If you require additional concaten-
  3823.     ations, you can use more APPEND commands:
  3824.     
  3825.     APPEND myvar "ABC" "DEF" "GHI" "JKL"
  3826.     APPEND myvar myvar "MNO" "PQR"
  3827.     
  3828.     The first line sets the variable myvar to "ABCDEFGHIJKL".  The second line
  3829.     set myvar to its previous value, plus "MNOPQR", so that its final value is
  3830.     "ABCDEFGHIJKLMNOPQR".
  3831.     
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.  
  3844.  
  3845.  
  3846.  
  3847.  
  3848.  
  3849.                                                                              61
  3850.                                 -------------------
  3851.                                 The OVERLAY Command
  3852.                                 -------------------
  3853.     
  3854.     FORMAT:        OVERLAY var1 value1 value2
  3855.     
  3856.     PURPOSE:       The OVERLAY command overwrites a portion of a variable with
  3857.                    a value, at the specified position.  The length of the
  3858.                    variable is padded with spaces if necessary.
  3859.     
  3860.     PARAMETERS:    var1   is the variable to be overwritten
  3861.                    value1 is the data which will be placed into var1
  3862.                    value2 is the position, in var1, where value1 will be placed
  3863.     
  3864.     NOTES:         No variable can hold more than 255 characters.
  3865.     
  3866.     NUMERICS:      Tabs, spaces and commas are stripped from value2
  3867.                    value2 must be between "1" and "255"
  3868.     
  3869.     SEE ALSO:      "The Append Command" and "The Insert Command"
  3870.     
  3871.     The OVERLAY command lets you replace part of a variable, starting at a
  3872.     particular position.  Here is an example:
  3873.     
  3874.     SET      x = "ABCDEFG"
  3875.     SET      y = "pom"
  3876.     OVERLAY  x y "4"
  3877.     
  3878.     This will change the x variable so it contains "ABCpomG", since it places
  3879.     the "pom" at position "4".
  3880.     
  3881.     If value2 is greater than the length of var1, var1 is padded with spaces to
  3882.     allow value2 to be placed at the specified position.  For example:
  3883.     
  3884.     SET      x = "ABCDEFG"
  3885.     SET      y = "pom"
  3886.     OVERLAY  x y "10"
  3887.     
  3888.     This will change the x variable to "ABCDEFG  pom".  Since var1 was less than
  3889.     10 characters, it had to be extended to allow the "pom" to start in position
  3890.     "10".
  3891.     
  3892.     Since no variable can be more than 255 characters, OVERLAY will truncate the
  3893.     result if it extends beyond that:
  3894.     
  3895.     SET      x = "ABCDEFG"
  3896.     SET      y = "pom"
  3897.     OVERLAY  x y "254"
  3898.     
  3899.     The x variable will be 255 characters long (starting with "ABCDEFG",
  3900.     followed by many spaces) and end with "po", since the "p" is in position
  3901.     "254" and the "o" is in the last legal position (i.e. "255").
  3902.     
  3903.  
  3904.                                                                              62
  3905.     Here are some additional examples:
  3906.     
  3907.     SET      x = ""        <-- Set x to a null (empty) string
  3908.     OVERLAY  x "ABC" "1"   <-- Set x to "ABC" (i.e. the "A" is at position "1")
  3909.     OVERLAY  x "DEF" "4"   <-- Change x from "ABC" to "ABCDEF"
  3910.     OVERLAY  x "IJ"  "9"   <-- Change x to "ABCDEF  IJ"
  3911.     OVERLAY  x "GH"  "7"   <-- Change x to "ABCDEFGHIJ"
  3912.     
  3913.     -------------
  3914.     Simple Arrays
  3915.     -------------
  3916.     
  3917.     You can use OVERLAY to perform some simple array processing, provided the
  3918.     total length of the data items does not exceed 255 characters.  For example,
  3919.     you could store 25 items of up to 10 characters each in a 250-character
  3920.     variable. Here is a helpful subroutine (see "The Code Command") for this
  3921.     kind of operation:
  3922.     
  3923.     CODE     "Calc Array Indexes"
  3924.       SET      ItemSize  = "10"
  3925.       CALC     IndexStart = Index- "*" ItemSize
  3926.       CALC     IndexEnd   = IndexStart "+" ItemSize
  3927.       SET      IndexStart = IndexStart+
  3928.     END
  3929.     
  3930.     This will provide pointers for an array of 25 items of up to 10 characters
  3931.     each, with indexes of 1 to 10. You can use this information with both the
  3932.     OVERLAY and COPY commands.  You could extract the 15th item as follows:
  3933.     
  3934.     SET      Index = "15"
  3935.     CALL     "Calc Array Indexes"
  3936.     COPY     x MyArray IndexStart IndexEnd
  3937.     
  3938.     For a more sophisticated and flexible method of handling arrays, see "Array
  3939.     Variables".
  3940.     
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.  
  3958.  
  3959.                                                                              63
  3960.                                 -------------------
  3961.                                 The MAPFILE Command
  3962.                                 -------------------
  3963.     
  3964.     FORMAT:        value1 value2 [value3]
  3965.     
  3966.     PURPOSE:       MAPFILE reads a file containing data for the REMAP command
  3967.     
  3968.     PARAMETERS:    value1 is the name of the map file
  3969.                    value2 is the map name, used by the REMAP command
  3970.                    value3 is the control settings (AnyCase/MatchCase/Transpose)
  3971.     
  3972.     DEFAULTS:      value3 = "MATCHCASE"
  3973.     
  3974.     NOTES:         The maximum length of a map name is 12 characters
  3975.     
  3976.     SEE ALSO:      "The Remap Command", "How Parse-O-Matic Searches for a File"
  3977.     
  3978.     The MAPFILE command reads in a file which contains data for the REMAP
  3979.     command, and assigns a name to the collection of data so the REMAP command
  3980.     can refer to it.
  3981.     
  3982.     -------------------
  3983.     What is a Map File?
  3984.     -------------------
  3985.     
  3986.     A map file is an ordinary text file; you can create or edit the file with a
  3987.     standard text editor, or a word-processor in "generic text" mode. Map files
  3988.     are usually given the .MPF extension.
  3989.     
  3990.     A map file contains a list of "mappings".  Here are some other words with
  3991.     approximately the same meaning as "mapping":
  3992.     
  3993.       Translation   Correlation   Substitution   Equivalence   Replacement
  3994.     
  3995.     In other words, the map file contains a list of data items that should be
  3996.     replaced by other data items.
  3997.     
  3998.     ----------------
  3999.     Sample Map Files
  4000.     ----------------
  4001.     
  4002.     The following map files are included in the standard Parse-O-Matic package:
  4003.     
  4004.     FILE NAME     DESCRIPTION
  4005.     ------------  ----------------------------------------------------------
  4006.     BIN2CHAR.MPF  Converts binary data into printable characters and periods
  4007.     BIN2CODE.MPF  Converts binary data into hex codes (e.g. 3F 2C A3)
  4008.     ASC2EBCD.MPF  Converts ASCII data to EBCDIC and vice-versa
  4009.     
  4010.  
  4011.  
  4012.  
  4013.  
  4014.                                                                              64
  4015.     ---------------
  4016.     Map File Format
  4017.     ---------------
  4018.     
  4019.     The map file contains one mapping per line.  Each mapping consists of two
  4020.     Parse-O-Matic literals, separated by one or more spaces or tabs. The first
  4021.     value is the "find" column, while the second value is the "replace" column.
  4022.     Here are some examples:
  4023.     
  4024.     "123"  "LOS ANGELES"      <-- Both values are "literal text strings"
  4025.     $39    "9"                <-- A hex code and a literal text string
  4026.     #48    "Zero"             <-- A decimal code and a literal text string
  4027.     $FF$30 #00#00             <-- Hex and decimal literals
  4028.     
  4029.     These columns are lined up for clarity; there is no need to start in a
  4030.     particular column.  Any leading or trailing spaces are removed from a
  4031.     line, and any number of spaces or tabs can appear between the columns.
  4032.     
  4033.     The following line is NOT valid:
  4034.     
  4035.     123    LOS ANGELES
  4036.     
  4037.     The line must use text, hex or decimal literals (e.g. "text", $FF, #FF).
  4038.     
  4039.     Null or blank lines, or lines that start with a semicolon, are ignored.
  4040.     The longest line that can be specified is 255 characters.  The longest
  4041.     value that can be specified is 80 characters (after translation, if it
  4042.     is in hex or decimal mode).
  4043.     
  4044.     ------------
  4045.     Search Order
  4046.     ------------
  4047.     
  4048.     The REMAP command performs substitutions in the order that they appear in
  4049.     the map file.  In most cases, the longer "find" strings should appear
  4050.     first.  For example, let us say you create a map file named FORWARD.MPF,
  4051.     which looks like this:
  4052.     
  4053.     "123"   "in Los Angeles"
  4054.     "12"    "in Montreal"
  4055.     "1"     "in Town of Mount Royal"
  4056.     "2"     "in Podunk"
  4057.     
  4058.     Now let's say you run the following POM file, named FORWARD.POM:
  4059.     
  4060.     MAPFILE "FORWARD"
  4061.     SET     comment = "Forward the memo to office 123"
  4062.     REMAP   comment
  4063.     OUTEND  |{comment}
  4064.     
  4065.     This will produce the following output:
  4066.     
  4067.  
  4068.  
  4069.                                                                              65
  4070.     Forward the memo to office in Los Angeles
  4071.     
  4072.     This happens because the string "123" is replaced by the string "in Los
  4073.     Angeles".
  4074.     
  4075.     If the order of the lines in FORWARD.MPF are reversed, FORWARD.POM will
  4076.     produce the following output:
  4077.     
  4078.     Forward memo to Office in Town of Mount RoyalinPodunk3
  4079.     
  4080.     This happens because the "1" is found (and replaced) first, followed by the
  4081.     "2".  Since there is no "3" in FORWARD.MPF, it is left alone.
  4082.     
  4083.     Parse-O-Matic does NOT enforce the principle of "progressively shorter
  4084.     'find' strings".  If you are processing a lot of data, you can improve
  4085.     processing speed slightly by placing a short, frequently-used "find" string
  4086.     near the top of the list.  As long as it is not a sub-string of (i.e.
  4087.     contained within) one of the following strings, it will not cause any
  4088.     problems.
  4089.     
  4090.     -------------
  4091.     Case Matching
  4092.     -------------
  4093.     
  4094.     You can set value3 to "AnyCase" or "MatchCase" (the default).
  4095.     
  4096.     ANYCASE:    The find string need not match in case ("John" = "JOHN")
  4097.     MATCHCASE:  The find string must match ("John" does not match "JOHN")
  4098.     
  4099.     Processing is faster if you use the default setting (MatchCase).
  4100.     
  4101.     ---------------
  4102.     Reverse Mapping
  4103.     ---------------
  4104.     
  4105.     If you want the mapping process to work "backwards", you can use the
  4106.     "Transpose" control setting in value3.  For example:
  4107.     
  4108.     MAPFILE "MYFILE.MPF" "MYFILE" "AnyCase Transpose"
  4109.     
  4110.     This reverses the mapping process:  the "find" column is treated like the
  4111.     "replace with" column, and vice-versa.
  4112.     
  4113.     The standard Parse-O-Matic package contains a map file (ASC2EBCD.MPF) which
  4114.     will translate ASCII files into EBCDIC files -- and vice-versa.
  4115.     
  4116.     NOTE:  EBCDIC is a character representation used on certain large mainframe
  4117.            computers.  Both ASCII and EBCDIC characters are eight bits long,
  4118.            but EBCDIC uses different bit patterns for most characters.
  4119.     
  4120.     Since both the "find" and "replace with" columns in ASC2EBCD.MPF are only
  4121.     one character wide, and since there is no duplication within either column,
  4122.     the translation process is perfectly reversible.  For example:
  4123.  
  4124.                                                                              66
  4125.     PROLOGUE
  4126.       CHOP     1 20                                <-- Read 20 bytes at a time
  4127.       MAPFILE  "ASC2EBCD.MPF" "EBCDIC"             <-+
  4128.       MAPFILE  "ASC2EBCD.MPF" "ASCII" "TRANSPOSE"    | Set up maps
  4129.       MAPFILE  "BIN2CODE.MPF" "CODE"               <-+
  4130.     END
  4131.     SET      x = $FLINE                            <-+
  4132.     REMAP    x "CODE"                                | Display original text in
  4133.     OUTEND   |[ORIGINAL] [{$FLINE}]                  | normal & hex-coded form
  4134.     OUTEND   |[ORIGINAL] [{x}]                     <-+
  4135.     REMAP    $FLINE "EBCDIC"                       <-+
  4136.     SET      x = $FLINE                              | Convert to EBCDIC and
  4137.     REMAP    x "CODE"                                | display in coded form
  4138.     OUTEND   |[EBCDIC  ] [{x}]                     <-+
  4139.     REMAP    $FLINE "ASCII"                        <-+
  4140.     SET      x = $FLINE                              | Convert EBCDIC back to
  4141.     REMAP    x "CODE"                                | ASCII; display hex code
  4142.     OUTEND   |[ASCII   ] [{x}]                     <-+
  4143.     OUTEND   |                                     <-- Output a separator line
  4144.     
  4145.     You can run this POM file against any file, then view the output file.  You
  4146.     will see how the original text is converted into EBCDIC and then the EBCDIC
  4147.     is converted back to ASCII.  (Most of the data in the output file is
  4148.     represented in "hex dump" format, since your computer is not designed to
  4149.     display EBCDIC.)
  4150.     
  4151.     TRANSPOSE will often let you use a single map file instead of two, but
  4152.     before using this technique you should carefully consider how mapping will
  4153.     take place (see "Irreversible Mapping", below).
  4154.     
  4155.     --------------------
  4156.     Irreversible Mapping
  4157.     --------------------
  4158.     
  4159.     Consider the following POM file:
  4160.     
  4161.     MAPFILE "MYMAP.MPF" "XYZ"
  4162.     MAPFILE "MYMAP.MPF" "ZYX" "TRANSPOSE"
  4163.     REMAP   $FLINE "XYZ"
  4164.     REMAP   $FLINE "ZYX"
  4165.     OUTEND  |{$FLINE}
  4166.     
  4167.     In many cases, this is equivalent to the following one-line POM file:
  4168.     
  4169.     OUTEND  |{$FLINE}
  4170.     
  4171.     because the first REMAP changes $FLINE one way, and the second REMAP
  4172.     changes it back.
  4173.     
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179.                                                                              67
  4180.     This is not true in ALL cases, however.  In some circumstances a REMAP is
  4181.     not reversible.  Consider the following map file:
  4182.     
  4183.     "XYZ"  "CAB"
  4184.     "ABC"  "C"
  4185.     "DEF"  "ABC"
  4186.     
  4187.     Now consider the following sequence of events.  (The * and # characters
  4188.     show what gets replaced in each step.)
  4189.     
  4190.                  Original string   . . . . . . . . .   ABCDEF
  4191.                                                        ***###
  4192.     
  4193.                                                        *###
  4194.                  Remap produces this result  . . . .   CABC
  4195.                                                        ***
  4196.     
  4197.                                                        ***
  4198.                  Transposed remap of result  . . . .   XYZC
  4199.     
  4200.     If you follow the steps of the substitutions, you will see where the
  4201.     confusion arises.  As a general rule, simple substitutions (with no
  4202.     duplications in whole or in part) are reversible, but if you have any
  4203.     doubts, you can always take the safe route and use a separate map file
  4204.     for each direction.  (See "Search Order", above, for additional insight
  4205.     into this matter.)
  4206.     
  4207.     ------------------
  4208.     Memory Limitations
  4209.     ------------------
  4210.     
  4211.     The MAPFILE command reads the map data into RAM memory.  You will normally
  4212.     have sufficient memory for thousands of bytes worth of mappings. However,
  4213.     if you do not have enough memory to hold the data, Parse-O-Matic will
  4214.     display an error message, then terminate.  (See "Solving Memory Problems")
  4215.     
  4216.     To help you track memory usage, the MAPFILE command records memory status
  4217.     (bytes used and bytes left) in the processing log (see "Logging").
  4218.     
  4219.     -----------------------
  4220.     An Example of Remapping
  4221.     -----------------------
  4222.     
  4223.     The standard Parse-O-Matic package contains two sample map files:
  4224.     
  4225.     BIN2CODE.MPF maps single bytes to hex codes  (e.g. Hex $31 becomes "31 ")
  4226.     BIN2CHAR.MPF maps single bytes to either printable characters or periods
  4227.     
  4228.     You can view these files with the SEE program (included with Parse-O-Matic)
  4229.     or you can load them into a text editor program.
  4230.     
  4231.     Here is a POM file that uses the sample map files to create a hex dump of a
  4232.     binary file:
  4233.  
  4234.                                                                              68
  4235.     CHOP    1 16                  <-- Read the file 16 bytes at a time
  4236.     SETLEN  w $FLINE              <-- Get the actual number of bytes read
  4237.     BEGIN w <> "16"
  4238.       PAD $FLINE "R" #0 "16"      <-- If less than 16 bytes, pad with nulls
  4239.     END
  4240.     SET     x = $FLINE            <-- Make a copy of $FLINE
  4241.     SET     y = $FLINE            <-- Make a copy of $FLINE
  4242.     MAPFILE "BIN2CHAR" "CHAR"     <-- See Note
  4243.     MAPFILE "BIN2CODE.MPF" "CODE"
  4244.     REMAP   x "CHAR"              <-- Change the bytes to printable characters
  4245.     REMAP   y "CODE"              <-- Change the bytes to hex codes
  4246.     OUTEND  |x y                  <-- Output the line
  4247.     
  4248.     Note:  Since the file name (value1) does not have an extension,
  4249.            Parse-O-Matic will add the .MPF extension.  Thus, the actual file
  4250.            name Parse-O-Matic looks for is "BIN2CHAR.MPF".
  4251.     
  4252.                                  -----------------
  4253.                                  The REMAP Command
  4254.                                  -----------------
  4255.     
  4256.     FORMAT:        REMAP var1 value1
  4257.     
  4258.     PURPOSE:       REMAP transforms sub-strings into other strings
  4259.     
  4260.     PARAMETERS:    var1   is the variable being transformed
  4261.                    value1 is the map name (see "The MapFile Command")
  4262.     
  4263.     ALTERNATIVES:  The LOOKUP and CHANGE commands
  4264.     
  4265.     SEE ALSO:      "The MapFile Command"
  4266.     
  4267.     The REMAP command performs intensive substitutions on a variable.  It is
  4268.     equivalent to a large number of CHANGE commands, but has the following
  4269.     advantages:
  4270.     
  4271.     - It is faster than using a large number of CHANGEs
  4272.     - It does not expend your available values (see "Values")
  4273.     - It prevents multiple substitutions
  4274.     
  4275.     -------------------
  4276.     REMAP Versus CHANGE
  4277.     -------------------
  4278.     
  4279.     The "multiple substitution" issue is most important distinction between
  4280.     CHANGE and REMAP.  REMAP protects substituted text from being
  4281.     resubstituted.  Consider the following POM lines:
  4282.     
  4283.     SET    x = "cat dog mouse"
  4284.     CHANGE x "cat" "dog"
  4285.     CHANGE x "dog" "cat"
  4286.     
  4287.  
  4288.  
  4289.                                                                              69
  4290.     You might expect these lines to change x to "Dog Cat Mouse", but the actual
  4291.     result is "cat cat mouse".  The first CHANGE command sets the x variable to
  4292.     "dog dog mouse".  The next command changes the cats into dogs!
  4293.     
  4294.     You can avoid this problem by using intermediate substitutions or some such
  4295.     work-around, but this ends up complicating the POM file considerably.
  4296.     Moreover, this approach can be unwieldy if you have to perform a large
  4297.     number of substitutions.
  4298.     
  4299.     -----------
  4300.     Using REMAP
  4301.     -----------
  4302.     
  4303.     To accomplish the "cat/dog" substitution mentioned earlier, you can create
  4304.     a map file (named CATDOG.MPF) with a text editor.  It will look like this:
  4305.     
  4306.     "cat"  "dog"
  4307.     "dog"  "cat"
  4308.     
  4309.     Your POM file will then look like this:
  4310.     
  4311.     MAPFILE "CATDOG.MPF" "PETS"
  4312.     SET     x = "cat dog mouse"
  4313.     REMAP   x "PETS"
  4314.     
  4315.     This will change the x variable to "dog cat mouse".
  4316.     
  4317.     For another example of the REMAP command, see "The MapFile Command".
  4318.     
  4319.     
  4320.     
  4321.  
  4322.  
  4323.  
  4324.  
  4325.  
  4326.  
  4327.  
  4328.  
  4329.  
  4330.  
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336.  
  4337.  
  4338.  
  4339.  
  4340.  
  4341.  
  4342.  
  4343.  
  4344.                                                                              70
  4345.     ============================================================================
  4346.                                  FREE-FORM COMMANDS
  4347.     ============================================================================
  4348.     
  4349.                             ----------------------------
  4350.                             What are Free-Form Commands?
  4351.                             ----------------------------
  4352.     
  4353.     The free-form commands are used for extracting information from an input
  4354.     line that does not have its data in precise columns.  Consider the
  4355.     following input file:
  4356.     
  4357.     Mouse     Gazelle   Mouse     Elephant
  4358.     Dog       Giraffe   Elk       Mongoose
  4359.     Monkey    Snake     Caribou   Trout
  4360.     |         |         |         |
  4361.     Column 1  Col 11    Col 21    Col 31
  4362.     
  4363.     Extracting data that is arranged in tidy columns is simple -- all you need
  4364.     is the SET command.  However, you will need a more powerful command if the
  4365.     data is "free-form", like this:
  4366.     
  4367.     Mouse,Gazelle,Mouse,Elephant
  4368.     Dog,Giraffe,Elk,Mongoose
  4369.     Monkey,Snake,Caribou,Trout
  4370.     
  4371.     The data is not arranged in tidy columns.  For tasks like this, you need
  4372.     the free-form commands.
  4373.     
  4374.  
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.                                                                              71
  4400.                                  -----------------
  4401.                                  The PARSE Command
  4402.                                  -----------------
  4403.     
  4404.     FORMAT:        PARSE var1 value1 value2 value3 [value4]
  4405.                          :    :      :      :       :
  4406.     MEANING:       Variable   Source From   To      Control
  4407.     
  4408.     PURPOSE:       PARSE sets var1 to the text (found in value1) between
  4409.                    text fragments specified by value2 and value3.
  4410.     
  4411.     PARAMETERS:    var1   is the variable being set
  4412.                    value1 is the source text being read
  4413.                    value2 specifies the starting position
  4414.                    value3 specifies the ending position
  4415.                    value4 is the optional control setting
  4416.     
  4417.     DEFAULTS:      value4 = "X"
  4418.     
  4419.     ALTERNATIVES:  The PEEL command, and COPY used with FINDPOSN
  4420.     
  4421.     Consider the the following free-form data:
  4422.     
  4423.     Mouse,Gazelle,Mouse,Elephant
  4424.     Dog,Giraffe,Elk,Mongoose
  4425.     Monkey,Snake,Caribou,Trout
  4426.     
  4427.     The PARSE command lets you extract the "Nth" item.  For example, to extract
  4428.     the third item in each line in the free-form example above, you could use
  4429.     this command:
  4430.     
  4431.     PARSE  xyz  $FLINE  "2*,"  "3*,"
  4432.     
  4433.     This means "set the variable xyz by looking in $FLINE (the line just read
  4434.     from the input file) and taking everything between the second comma and the
  4435.     third comma".  For the three lines in the sample input file, the variable
  4436.     xyz is set to Mouse, then Elk, then Caribou.
  4437.     
  4438.     -------------
  4439.     Decapsulators
  4440.     -------------
  4441.     
  4442.     In the "From" specification in the previous example (i.e. the "2*," part
  4443.     of the command):
  4444.     
  4445.           2    means "the second occurrence"
  4446.           *    is a delimiter to mark the end of the occurrence number
  4447.           ,    is the text you are looking for
  4448.     
  4449.     Both the "From" and "To" specifications use this format.  Commands using
  4450.     this format are said to use "decapsulators", because you are extracting
  4451.     text that is encapsulated (i.e. surrounded) by other text.
  4452.     
  4453.  
  4454.                                                                              72
  4455.     Decapsulators may be used to find more than a single character.  The
  4456.     surrounding text can be up to 80 characters long.  Let's say the input file
  4457.     looks like this:
  4458.     
  4459.     Mouse%:Gazelle%:Mouse%:Elephant
  4460.     Dog%:Giraffe%:Elk%:Mongoose
  4461.     Monkey%:Snake%:Caribou%:Trout
  4462.     
  4463.     You can extract the third item in each line with this command:
  4464.     
  4465.            PARSE  xyz  $FLINE  "2*%:"  "3*%:"
  4466.                   ___  ______   _ ___    _ ___
  4467.                    |     |      |  |     |  |
  4468.      Variable to set     |      |  |     |  |
  4469.         The value to parse      |  |     |  "To" text being sought
  4470.          "From" occurrence number  |     "To" occurrence number
  4471.             "From" text being sought
  4472.     
  4473.     This command sets the variable xyz to Mouse, then Elk, then Caribou.
  4474.     
  4475.     ------------------
  4476.     Sample Application
  4477.     ------------------
  4478.     
  4479.     The PARSE command is particularly useful for extracting information from
  4480.     comma-delimited files.  Here is an example of a comma-delimited file:
  4481.     
  4482.     "Mouse","Gazelle","Mouse","Elephant"
  4483.     "Dog","Giraffe","Elk","Mongoose"
  4484.     "Monkey","Snake","Caribou","Trout"
  4485.     
  4486.     You can extract all the fields with this series of commands (note the use
  4487.     of doubled-up quotes to represent a single quotation mark -- see the
  4488.     section "Delimiters" for details):
  4489.     
  4490.     PARSE  field1  $FLINE  "1*"""  "2*"""
  4491.     PARSE  field2  $FLINE  "3*"""  "4*"""
  4492.     PARSE  field3  $FLINE  "5*"""  "6*"""
  4493.     PARSE  field4  $FLINE  "7*"""  "8*"""
  4494.     
  4495.     For the first line of the sample input file, field1 is set to Mouse, field2
  4496.     is set to Gazelle, and so on.
  4497.     
  4498.     --------------------
  4499.     The Occurence Number
  4500.     --------------------
  4501.     
  4502.     The occurrence number must be between 1 and 255.  The following lines are
  4503.     not valid PARSE commands:
  4504.     
  4505.     PARSE  xyz  $FLINE  "0*,"  "1*,"    <-- "From" decapsulator invalid: uses 0
  4506.     PARSE  xyz  $FLINE  "1*,"  "256*,"  <-- "To" decapsulator invalid: uses 256
  4507.     
  4508.  
  4509.                                                                              73
  4510.     The occurrence number must always be followed by a "*" so you can search
  4511.     for a number.  Consider the following example (the meaning of which would
  4512.     be unclear without the "*" delimiter):
  4513.     
  4514.     PARSE  xyz  "XXX2YYY2ZZZ2"  "1*2"  "2*2"
  4515.     
  4516.     This sets xyz to the text occuring between the first "2" and the second
  4517.     "2".  In other words, xyz is set to "YYY".
  4518.     
  4519.     --------------------------
  4520.     Finding the Last Occurence
  4521.     --------------------------
  4522.     
  4523.     A decapsulator can refer to "the LAST occurence":
  4524.     
  4525.     PARSE  xyz  "AaaBAbbBAccB"  ">*A"  ">*B"
  4526.     
  4527.     In both decapsulators, the ">" symbol means "the last occurence".  Thus,
  4528.     the command tells Parse-O-Matic, "Set the xyz variable to everything
  4529.     between the last A and the last B".  This sets the xyz variable to "cc".
  4530.     
  4531.     You can also use the "<" character to mean "the FIRST occurence", although
  4532.     this is somewhat redundant, since the following commands are equivalent:
  4533.     
  4534.     PARSE  xyz  "AaaBAbbBAccB"  "<*A"  "<*B"
  4535.     PARSE  xyz  "AaaBAbbBAccB"  "1*A"  "1*B"
  4536.     PARSE  xyz  "AaaBAbbBAccB"  "A"  "B"
  4537.     
  4538.     All three commands set the xyz variable to "aa".
  4539.     
  4540.     ---------------------
  4541.     Unsuccessful Searches
  4542.     ---------------------
  4543.     
  4544.     If PARSE does not find the search text, the variable will be set to a null
  4545.     ("").  Here are two examples:
  4546.     
  4547.     PARSE  abc  "ABCDEFGHIJ"  "1*K"  "1*J"   <-- There is no "K"
  4548.     PARSE  abc  "ABCDEFGHIJ"  "1*A"  "1*X"   <-- There is no "X"
  4549.     
  4550.     If the "from" value is less than the "to" value, Parse-O-Matic will display
  4551.     an error message, then terminate.  For example:
  4552.     
  4553.     PARSE  abc  "ABCDEFGHIJ"  "1*J"  "1*A"   <-- "J" comes after "A"
  4554.     
  4555.     This kind of failure typically happens if the input data contains an odd
  4556.     arrangement of text that you had not foreseen.
  4557.     
  4558.  
  4559.  
  4560.  
  4561.  
  4562.  
  4563.  
  4564.                                                                              74
  4565.     -------------------
  4566.     The Control Setting
  4567.     -------------------
  4568.     
  4569.     The PARSE command has an optional "Control" parameter, which tells PARSE
  4570.     whether to include or exclude the surrounding text that was found.  By
  4571.     default (as shown in all of the preceding examples), the delimiting text
  4572.     is excluded.  However, if you want to include it, you can add "I" at the
  4573.     end of the PARSE command, as in this example:
  4574.     
  4575.     PARSE  xyz  "aXcaYcaZc"  "2*a"  "2*c"  "I"
  4576.     
  4577.     This tells Parse-O-Matic to give you everything between the second "a" and
  4578.     the second "c" -- including the "a" and "c".  In other words, this sets the
  4579.     variable xyz to "aYc".  You can also set the Control specification to "X"
  4580.     (meaning "exclude"), although since this is the default setting for PARSE,
  4581.     it really isn't necessary.  Here is an example:
  4582.     
  4583.     PARSE  xyz  "a1ca2ca3c"  "2*a"  "2*c"  "X"
  4584.     
  4585.     This sets the variable xyz to "2".
  4586.     
  4587.     ----------------------
  4588.     The Plain Decapsulator
  4589.     ----------------------
  4590.     
  4591.     The occurrence number is not always needed.  Either the "From" or "To"
  4592.     decapsulator can be represented as a plain string, as follows:
  4593.     
  4594.     PARSE $FLINE "ABC" "XYZ"
  4595.     
  4596.     This means:
  4597.     
  4598.     - Start at the first "ABC" found in the value being parsed
  4599.     - End with the first "XYZ" found in the value being parsed
  4600.     
  4601.     ---------------------
  4602.     The Null Decapsulator
  4603.     ---------------------
  4604.     
  4605.     Here is helpful variation of the "From" decapsulator:
  4606.     
  4607.     ""   means "Start from the first character in the value being parsed"
  4608.     
  4609.     A similar variation can be used with the "To" decapsulator:
  4610.     
  4611.     ""   means "End with the last character in the value being parsed"
  4612.     
  4613.     If you use the null ("") decapsulator for "From" or "To", the "found" value
  4614.     (the first character for "From", or the last character for "To") will
  4615.     always be included (see "Overlapping Decapsulators" for the single
  4616.     exception to this rule).  Here is an example:
  4617.     
  4618.  
  4619.                                                                              75
  4620.     PARSE  xyz  "ABCABCABC"  ""  "2*C"
  4621.     
  4622.     This sets the variable xyz to "ABCAB".  The "From" value (i.e. the first
  4623.     character) is NOT excluded.  However, when PARSE finds the "To" value (i.e.
  4624.     the second occurrence of the letter C) it IS excluded.  If you want to
  4625.     include the second "C", you should write the command this way:
  4626.     
  4627.     PARSE  xyz  "ABCABCABC"  ""  "2*C"  "I"
  4628.     
  4629.     The following two commands accomplish the same thing:
  4630.     
  4631.     PARSE  xyz  "ABCD"  ""  ""
  4632.     SET    xyz  "ABCD"
  4633.     
  4634.     They are equivalent because the PARSE command means "Set the variable xyz
  4635.     with everything between (and including) the first and last character".
  4636.     
  4637.     -----------------------------------
  4638.     Null Decapsulators Versus Exclusion
  4639.     -----------------------------------
  4640.     
  4641.     The reason that PARSE treats the null ("") decapsulator differently may
  4642.     not be immediately obvious, since the examples given here are very simple,
  4643.     and not representative of "real world" applications. However, in day-to-day
  4644.     usage, you will frequently find it helpful to be able to specify a command
  4645.     that says, "Give me everything from the beginning of the line to just
  4646.     before such-and-such".
  4647.     
  4648.     Here is a command that means "Give me everything from just after the dollar
  4649.     sign, to the end of the line":
  4650.     
  4651.     PARSE  xyz  "I'd like to have $250.00"  "1*$"  ""
  4652.     
  4653.     This sets xyz to "250.00".  If you want to include the dollar sign, write
  4654.     the command this way:
  4655.     
  4656.     PARSE  xyz  "I'd like to have $250.00"  "1*$"  ""  "I"
  4657.     
  4658.     -------------------------
  4659.     Overlapping Decapsulators
  4660.     -------------------------
  4661.     
  4662.     Earlier, it was mentioned that the text found by the null decapsulator is
  4663.     "always included" and is not affected by the "X" (Exclude) control.  There
  4664.     is one exception to this:  if the null decapsulator's "found text" is
  4665.     contained in the text found by the other decapsulator, it WILL be affected.
  4666.     For example:
  4667.     
  4668.     PARSE x "ABCDEFABCDEF" "" "1*AB" "X"
  4669.     
  4670.     This command tells Parse-O-Matic "give me everything between the first
  4671.     character and the first occurence of AB".  Since the two items overlap
  4672.     (i.e. the first "AB" includes the first character), the first character
  4673.  
  4674.                                                                              76
  4675.     does indeed get excluded. As a result, the x variable is set to an empty
  4676.     string ("").
  4677.     
  4678.     Here is another example:
  4679.     
  4680.     PARSE x "ABCDEFABCDEF" ">*F" "" "X"
  4681.     
  4682.     This command tells Parse-O-Matic "give me everything between the last
  4683.     occurence of F and the last character".  Both decapsulators refer to the
  4684.     same character (i.e. the final "F"), so it is excluded. As a result, the x
  4685.     variable is set to an empty string ("").
  4686.     
  4687.     NOTE:  In some circumstances, the FINDPOSN command is NOT affected by this
  4688.            exception.  It will do its best to make sense of your request if the
  4689.            decapsulators overlap, and one of them is a null decapsulator.  For
  4690.            details, see "The FindPosn Command".
  4691.     
  4692.     --------------------
  4693.     Parsing Empty Fields
  4694.     --------------------
  4695.     
  4696.     Consider the following command:
  4697.     
  4698.     PARSE x ",,,JOHN,SMITH" "2*," "3*,"
  4699.     
  4700.     There is nothing between the second and third comma, so the x variable
  4701.     is set to "" (an empty string).
  4702.     
  4703.     Now consider this command:
  4704.     
  4705.     PARSE x ",,,JOHN,SMITH" "" ","
  4706.     
  4707.     You are asking for everything from the first character to the first
  4708.     comma (which also happens to be the first character).  Obviously, there is
  4709.     nothing "between" the two characters, so the x variable would be set to ""
  4710.     (an empty string).
  4711.     
  4712.     -------------------
  4713.     Additional Examples
  4714.     -------------------
  4715.     
  4716.     For more examples of the PARSE command, see the demonstrations provided
  4717.     with Parse-O-Matic (type START at the DOS prompt, or run START.BAT from
  4718.     Windows or OS/2, then select TUTORIAL).
  4719.     
  4720.  
  4721.  
  4722.  
  4723.  
  4724.  
  4725.  
  4726.  
  4727.  
  4728.  
  4729.                                                                              77
  4730.                                 ----------------
  4731.                                 The PEEL Command
  4732.                                 ----------------
  4733.     
  4734.     FORMAT:        PEEL  var1 var2   value1 value2 [value3]
  4735.                          :    :      :      :       :
  4736.     MEANING:       Variable   Source From   To      Control
  4737.     
  4738.     PURPOSE:       The PEEL command works just like PARSE, but after setting
  4739.                    var1, it REMOVES the parsed value (including the delimiters)
  4740.                    from var2.
  4741.     
  4742.     PARAMETERS:    var1   is the variable being set
  4743.                    var2   is the source text being read
  4744.                    value1 specifies the starting position
  4745.                    value2 specifies the ending position
  4746.                    value3 is the optional control setting
  4747.     
  4748.     DEFAULTS:      value3 = "X"
  4749.     
  4750.     When you are breaking up a complex line into fields, PEEL can simplify
  4751.     matters considerably, because the line being interpreted gradually becomes
  4752.     less complex.
  4753.     
  4754.     Here is a simple example.  Let's say you have an input file containing a
  4755.     single line:
  4756.     
  4757.     AA/BB/CC/DD
  4758.     
  4759.     If you run this POM file against the input file:
  4760.     
  4761.     PEEL   x $FLINE "" "/"       <-- Strip out the AA and remove the /
  4762.     OUTEND |{x}
  4763.     PEEL   x $FLINE "" "/"       <-- Strip out the BB and remove the /
  4764.     OUTEND |{x}
  4765.     PEEL   x $FLINE "" "/"       <-- Strip out the CC and remove the /
  4766.     OUTEND |{x}
  4767.     OUTEND |{$FLINE}
  4768.     
  4769.     then the output file will look like this:
  4770.     
  4771.     AA
  4772.     BB
  4773.     CC
  4774.     DD
  4775.     
  4776.     What is happening is that $FLINE is gradually being stripped of the text
  4777.     that is being found.  After the first PEEL, $FLINE contains "BB/CC/DD",
  4778.     and so on.  After the final PEEL, $FLINE only contains "DD".
  4779.     
  4780.  
  4781.  
  4782.  
  4783.  
  4784.                                                                              78
  4785.     -------------------
  4786.     The Control Setting
  4787.     -------------------
  4788.     
  4789.     The "I" and "X" control parameters behave the same way as they do in the
  4790.     PARSE command: they specify whether or not the surrounding text is included
  4791.     in var1.  Take note, however, that the starting and ending characters
  4792.     are always removed from var2, along with the "found" text, regardless of
  4793.     the control parameter.  In other words, the control parameter only affects
  4794.     the first variable (x in the example above), not the second ($FLINE in the
  4795.     example).
  4796.     
  4797.     --------------------
  4798.     Parsing Empty Fields
  4799.     --------------------
  4800.     
  4801.     Consider the following commands:
  4802.     
  4803.     SET   z = ",,,JOHN,SMITH"
  4804.     PEEL  x z "2*," "3*,"
  4805.     
  4806.     There is nothing between the second and third comma, so the x variable
  4807.     is set to "" (an empty string).  After the PEEL command, the z variable
  4808.     will be two commas shorter (",JOHN,SMITH,23.00").  If you are trying to
  4809.     extract data from a comma-delimited line, this is probably not what you
  4810.     want (since it gets rid of two commas).  When taking apart a delimited
  4811.     file, it often makes sense to start peeling from the left side of the
  4812.     string.  Consider these commands:
  4813.     
  4814.     SET   z = ",,,JOHN,SMITH"
  4815.     PEEL  x z "" ","
  4816.     
  4817.     You are asking for everything from the first character to the first
  4818.     comma (which also happens to be the first character).  Obviously, there is
  4819.     nothing "between" the two characters, so the x variable would be set to ""
  4820.     (an empty string).  After the PEEL command, the z variable will be one
  4821.     comma shorter (",,JOHN,SMITH").
  4822.     
  4823.  
  4824.  
  4825.  
  4826.  
  4827.  
  4828.  
  4829.  
  4830.  
  4831.  
  4832.  
  4833.  
  4834.  
  4835.  
  4836.  
  4837.  
  4838.  
  4839.                                                                              79
  4840.     --------------------------
  4841.     The Left-Peeling Technique
  4842.     --------------------------
  4843.     
  4844.     You can use the "left-peeling" technique to take apart an entire line.  This
  4845.     is especially useful when interpreting a comma-delimited file.
  4846.     
  4847.     SET   z = ",,MARY,JONES,"
  4848.     PEEL  a z "" ","                 <-- Sets the a variable to ""
  4849.     PEEL  b z "" ","                 <-- Sets the b variable to ""
  4850.     PEEL  c z "" ","                 <-- Sets the c variable to "MARY"
  4851.     PEEL  d z "" ","                 <-- Sets the d variable to "JONES"
  4852.     SET   e = z                      <-- Sets the e variable to ""
  4853.     
  4854.     The e variable is null because there is nothing after the last comma -- in
  4855.     other words, the final field is empty.  If the initial value of the z
  4856.     variable was ",,MARY,JONES,99" then the e variable would be set to "99".
  4857.     
  4858.     ----------------------
  4859.     The Leftover Technique
  4860.     ----------------------
  4861.     
  4862.     Sometimes you are faced with a parsing task in which the input lines are
  4863.     more than 255 characters long, yet there is no way to know where each
  4864.     field begins.  This makes it impossible to use the SPLIT command in the
  4865.     usual way.
  4866.     
  4867.     This type of problem generally arises when processing comma-delimited or
  4868.     tab-delimited files.
  4869.     
  4870.     Here is a sample POM file which handles input lines up to 300 characters
  4871.     long, provided that no field is more than 155 characters long.
  4872.     
  4873.  
  4874.  
  4875.  
  4876.  
  4877.  
  4878.  
  4879.  
  4880.  
  4881.  
  4882.  
  4883.  
  4884.  
  4885.  
  4886.  
  4887.  
  4888.  
  4889.  
  4890.  
  4891.  
  4892.  
  4893.  
  4894.                                                                              80
  4895.     SPLIT    1-100, 101-200, 201-300   <-- Process input lines in three segments
  4896.     IGNORE   $FLINE = ""               <-- Ignore any splits that yield nothing
  4897.     BEGIN    leftover <> ""            <-- See if we have anything left over
  4898.       APPEND   $FLINE leftover $FLINE  <-- Append what's left over
  4899.       SET      leftover = ""           <-- We've used up the left over data
  4900.     END
  4901.     BEGIN                              <-- Loop through the parts we can extract
  4902.       FINDPOSN x $09                   <-- Look for a tab
  4903.       BEGIN    x <> "0"                <-- See if we found a tab
  4904.         SET      foundtab = "Y"        <-- Yes, we found a tab
  4905.         PEEL     x $FLINE "" #09       <-- Peel away everything up to the tab
  4906.         OUTEND   |{x}                  <-- Process the text we peeled away
  4907.       ELSE
  4908.         SET      foundtab = "N"        <-- No, we didn't find a tab
  4909.         BEGIN    $SPLIT = "3"          <-- See if this is the last of the text
  4910.           OUTEND   |{$FLINE}           <-- Output whatever is left over
  4911.         ELSE
  4912.           SET      leftover = $FLINE   <-- Save this part for the next split
  4913.         END
  4914.       END
  4915.     AGAIN    foundtab = "Y"            <-- Continue if this segment had a tab
  4916.     
  4917.     
  4918.     
  4919.  
  4920.  
  4921.  
  4922.  
  4923.  
  4924.  
  4925.  
  4926.  
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934.  
  4935.  
  4936.  
  4937.  
  4938.  
  4939.  
  4940.  
  4941.  
  4942.  
  4943.  
  4944.  
  4945.  
  4946.  
  4947.  
  4948.  
  4949.                                                                              81
  4950.     ============================================================================
  4951.                                 POSITIONAL COMMANDS
  4952.     ============================================================================
  4953.     
  4954.                                  ------------------
  4955.                                  General Discussion
  4956.                                  ------------------
  4957.     
  4958.     NOTE:  If you are a programmer, you may be tempted to use positional
  4959.            commands even when other Parse-O-Matic commands are more efficient.
  4960.            The positional approach is reminiscent of the parsing strategies
  4961.            used in traditional programming languages, so you may use them
  4962.            because of their familiarity.  The following material discusses
  4963.            this issue, to help you to create shorter, faster POM files.
  4964.     
  4965.     -----------------------------
  4966.     What are Positional Commands?
  4967.     -----------------------------
  4968.     
  4969.     Parse-O-Matic's positional commands let you work with the numeric position
  4970.     of one text string in another.  For example, if the variable xyz contains
  4971.     the value "ABCD":
  4972.     
  4973.     SEARCH   POSITION
  4974.     STRING    IN xyz    COMMENTS
  4975.     ------   --------   -----------------------------------------
  4976.     "A"        "1"      "A" appears in the 1st position of "ABCD"
  4977.     "AB"       "1"
  4978.     "ABCD"     "1"
  4979.     "C"        "3"      "C" appears in the 3rd position of "ABCD"
  4980.     "CD"       "3"
  4981.     "D"        "4"
  4982.     "AC"       "0"      "0" since "AC" does not appear in "ABCD"
  4983.     
  4984.     ----------------------------
  4985.     Why Use Positional Commands?
  4986.     ----------------------------
  4987.     
  4988.     Positional commands give you the precise control you need for certain
  4989.     difficult parsing tasks. For example, if you want to obtain the last three
  4990.     characters of a string of known length (e.g. "ABCDEFG"), the standard
  4991.     approach is:
  4992.     
  4993.     SET abc = "ABCDEFG"
  4994.     SET xyz = abc[5 7]
  4995.     
  4996.     However, if the length of the string is not known, you can not use the
  4997.     substrings in [square brackets].  (To make Parse-O-Matic run as fast as
  4998.     possible for standard parsing jobs, you can not use variables within
  4999.     square brackets.)
  5000.     
  5001.  
  5002.  
  5003.  
  5004.                                                                              82
  5005.     If the length of the string is not known, you need positional commands to
  5006.     obtain the last three characters.  Here is an example:
  5007.     
  5008.     SET    abc = "Unknown"
  5009.     SETLEN len abc
  5010.     CALC   lenminus = len "-" "2"
  5011.     COPY   xyz abc lenminus len
  5012.     
  5013.     The SETLEN command finds the length (i.e. the last position) of the abc
  5014.     variable.  In this case, the answer is "7", since "Unknown" is seven
  5015.     characters long.  The CALC command subtracts "2" from this length, setting
  5016.     the lenminus variable to "5".  Finally, the COPY command copies from
  5017.     position "5" to "7", setting the variable xyz to "own" -- the last three
  5018.     characters of the abc variable.
  5019.     
  5020.     -----------------
  5021.     A Cautionary Note
  5022.     -----------------
  5023.     
  5024.     Positional commands are useful for some applications, but many parsing jobs
  5025.     do not require them.  The commands SET, IF, PARSE and PEEL can usually do
  5026.     the same job with less effort. For example, the following approaches are
  5027.     equivalent:
  5028.     
  5029.                  STANDARD APPROACH       POSITIONAL APPROACH
  5030.                  -----------------       ---------------------
  5031.                  SET   abc "AB/CD"       SET      abc = "AB/CD"
  5032.                  PARSE xyz abc "/"       FINDPOSN n abc "/"
  5033.                                          COPY     xyz abc n+
  5034.     
  5035.     The positional approach requires more lines than the standard approach to
  5036.     extracting the characters after the "/" character.  Another problem is that
  5037.     because positional commands give you fine control of the parsing process,
  5038.     it is up to you to guard against exceptional situations.  Consider this
  5039.     example:
  5040.     
  5041.     FINDPOSN x $FLINE "/"
  5042.     CALC     x = x "+" "1"
  5043.     COPY     xyz $FLINE x
  5044.     
  5045.     If $FLINE (the current input line) contains the value "ABC/DEF":
  5046.     
  5047.     FINDPOSN sets x to "4" (the position of the "/" character)
  5048.     CALC     increases x to "5"
  5049.     COPY     sets xyz to "DEF" -- from position "5" to the end of $FLINE
  5050.     
  5051.     Unfortunately, a problem occurs if $FLINE does not contain a slash:
  5052.     
  5053.     FINDPOSN sets x to "0" (meaning the "/" was not found)
  5054.     CALC     increases x to "1"
  5055.     COPY     copies from position "1" to the end of $FLINE
  5056.     
  5057.  
  5058.  
  5059.                                                                              83
  5060.     This may not be what you intended.  If you want to return a null string
  5061.     when $FLINE does not contain a slash, you could use a single PARSE command:
  5062.     
  5063.     PARSE xyz $FLINE "/"
  5064.     
  5065.     This copies anything after the slash to the xyz variable.  If $FLINE does
  5066.     not contain a slash, xyz is set to "".
  5067.     
  5068.     The precise control provided by Parse-O-Matic's positional commands makes
  5069.     them indispensible for certain parsing applications.  Just remember that
  5070.     with added power comes added responsibility:  you will sometimes have to
  5071.     add extra code to handle unusual situations.
  5072.     
  5073.                                  ------------------
  5074.                                  The SETLEN Command
  5075.                                  ------------------
  5076.     
  5077.     FORMAT:        SETLEN var1 value1
  5078.     
  5079.     PURPOSE:       SETLEN sets var1 to the length of value1.
  5080.     
  5081.     Here is an example of the SETLEN command:
  5082.     
  5083.     SET    x = "ABCD"
  5084.     SETLEN y x
  5085.     
  5086.     This sets variable y to "4".
  5087.     
  5088.     One handy application for SETLEN is to underline text.  For example:
  5089.     
  5090.     SET     name = $FLINE[1 15]
  5091.     TRIM    name "B" " "
  5092.     SETLEN  nlen name
  5093.     SET     uline = ""
  5094.     PAD     uline "L" "-" nlen
  5095.     OUTEND  |{name}
  5096.     OUTEND  |{uline}
  5097.     
  5098.     If the input line contains the name "JOHN SMITH", the output would be:
  5099.     
  5100.     JOHN SMITH
  5101.     ----------
  5102.     
  5103.     For another example that does underlining, see "POM and Wildcards".
  5104.     
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.                                                                              84
  5115.                                  ------------------
  5116.                                  The DELETE Command
  5117.                                  ------------------
  5118.     
  5119.     FORMAT:        DELETE var1 value1 [value2]
  5120.     
  5121.     PURPOSE:       The DELETE command removes a range of characters (specified
  5122.                    as a starting and ending position) from a variable.
  5123.     
  5124.     PARAMETERS:    var1   is the variable from which characters will be removed
  5125.                    value1 is the starting position (e.g. "1" = First character)
  5126.                    value2 is the optional ending position; if it is omitted,
  5127.                           it is assumed to mean "the last character in var1"
  5128.     
  5129.     NOTES:         If value1 is null or "0", value1 = "1"
  5130.                    If value2 is null or "0", value2 = "last character in var1"
  5131.     
  5132.     ALTERNATIVES:  The PEEL, TRIM, CHANGE, SET and APPEND commands
  5133.     
  5134.     Here is an example of the DELETE command:
  5135.     
  5136.     SET    x = "ABC///DEF"
  5137.     DELETE x "4" "6"
  5138.     
  5139.     This deletes from position 4 to 6, so the variable x is set to "ABCDEF".
  5140.     
  5141.     If value2 is omitted, DELETE assumes you wish to delete everything from
  5142.     the starting position to the end of the string.  For example:
  5143.     
  5144.     SET    x = "ABC///DEF"
  5145.     DELETE x "4"
  5146.     
  5147.     This sets x to "ABC".
  5148.     
  5149.  
  5150.  
  5151.  
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.                                                                              85
  5170.                                   ----------------
  5171.                                   The COPY Command
  5172.                                   ----------------
  5173.     
  5174.     FORMAT:        COPY var1 value1 value2 [value3]
  5175.     
  5176.     PURPOSE:       The COPY command copies a range of characters (specified as
  5177.                    a starting and ending position) from a value to a variable.
  5178.     
  5179.     PARAMETERS:    var1   is the variable being set
  5180.                    value1 is the source value, from which you will copy text
  5181.                    value2 is the starting position (e.g. "1" = First character)
  5182.                    value3 is the optional ending position; if it is omitted,
  5183.                           it is assumed to mean "the last character in value1"
  5184.     
  5185.     NUMERICS:      Tabs, spaces and commas are stripped from value2 and value3
  5186.     
  5187.     NOTES:         If value2 is null or "0", value1 = "1"
  5188.                    If value3 is null or "0", value3 = "last char in value1"
  5189.     
  5190.     ALTERNATIVES:  The SET command
  5191.     
  5192.     Here is an example of the COPY command:
  5193.     
  5194.     SET    x = "ABC///DEF"
  5195.     COPY   y x "4" "6"
  5196.     
  5197.     This copies from position 4 to 6, so the variable y is set to "///".
  5198.     
  5199.     If value2 is omitted, COPY assumes you wish to copy everything from the
  5200.     starting position to the end of the string.  For example:
  5201.     
  5202.     SET    x = "ABC///DEF"
  5203.     COPY   y x "4"
  5204.     
  5205.     This sets y to "///DEF".
  5206.     
  5207.     To make your POM files easier to read, you might consider padding the
  5208.     COPY command with an equals sign to remind you that a variable is being
  5209.     set. For example:
  5210.     
  5211.     COPY   y = x "4" "6"
  5212.     
  5213.     This emphasizes that the variable y is being set to a substring of x.
  5214.     For more information about padding, see "Padding for Clarity".
  5215.     
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.                                                                              86
  5225.                                 -------------------
  5226.                                 The EXTRACT Command
  5227.                                 -------------------
  5228.     
  5229.     FORMAT:        EXTRACT var1 var2 value1 [value2]
  5230.     
  5231.     PURPOSE:       The EXTRACT command works like COPY, but removes the
  5232.                    characters from the source variable after copying them to
  5233.                    a variable.
  5234.     
  5235.     PARAMETERS:    var1   is the variable that will contain the characters
  5236.                           extracted from var2
  5237.                    var2   is the variable from which characters will be copied
  5238.                           to var1, then removed
  5239.                    value1 is the starting position (e.g. "1" = First character)
  5240.                    value2 is the optional ending position; if it is omitted,
  5241.                           it is assumed to mean "the last character in var2"
  5242.     
  5243.     NUMERICS:      Tabs, spaces and commas are stripped from value1 and value2
  5244.     
  5245.     NOTES:         If value1 is null or "0", value1 = "1"
  5246.                    If value2 is null or "0", value2 = "last character in var2"
  5247.     
  5248.     ALTERNATIVES:  The PEEL command
  5249.     
  5250.     Here is an example of the EXTRACT command:
  5251.     
  5252.     SET     x = "ABC///DEF"
  5253.     EXTRACT y x "4" "6"
  5254.     
  5255.     This copies from position 4 to 6, so the variable y is set to "///".
  5256.     The characters copied to variable y are removed from x, so that it now
  5257.     contains the value "ABCDEF".
  5258.     
  5259.     If value2 is omitted, EXTRACT assumes you wish to extract everything from
  5260.     the starting position to the end of the string.  For example:
  5261.     
  5262.     SET     x = "ABC///DEF"
  5263.     EXTRACT y x "4"
  5264.     
  5265.     This sets y to "///DEF", while the variable x is set to "ABC" (i.e. the
  5266.     original value for x, with the extracted characters removed).
  5267.     
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.                                                                              87
  5280.                                 --------------------
  5281.                                 The FINDPOSN Command
  5282.                                 --------------------
  5283.     
  5284.     FORMAT:        FINDPOSN var1 value1 value2 [value3 [value4]]
  5285.                             :    :      :       :       :
  5286.     MEANING:       1) Variable   Source Find    :       :
  5287.                    2) Variable   Source From    To      Control
  5288.     
  5289.     PURPOSE:       The FINDPOSN command finds one text string in another.  It
  5290.                    locates the starting or ending position of a string, or
  5291.                    a string delimited by one or two other strings.
  5292.     
  5293.     PARAMETERS:    var1   is the variable that will contain the position if
  5294.                           the string is found (e.g. "2" means it was found
  5295.                           in the second position of value1; "0" means the
  5296.                           string was not found)
  5297.                    value1 is the string being searched
  5298.                    value2 is the string being sought, or...
  5299.                              the left-most part of a string being sought
  5300.                    value3 is the right-most part of the string being sought;
  5301.                              if it is set to null (""), it is assumed to mean
  5302.                              "the last character in value1"
  5303.                    value4 is the control setting
  5304.     
  5305.     DEFAULTS:      value4 = "IS"
  5306.     
  5307.     ALTERNATIVES:  The SCANPOSN command
  5308.     
  5309.     SEE ALSO:      This section is much easier to understand if you have
  5310.                    studied "The Parse Command".
  5311.     
  5312.     There are two ways to use the FINDPOSN command:  the "Plain String Find"
  5313.     and the "Embedded String Find".  These are discussed below.
  5314.     
  5315.     ---------------------
  5316.     The Plain String Find
  5317.     ---------------------
  5318.     
  5319.     In its simplest form, the Plain String Find locates a string (value2) in
  5320.     another string (value1) and assigns its position to a variable (var1).
  5321.     Here is an example:
  5322.     
  5323.     FINDPOSN x $FLINE "Fred"
  5324.     
  5325.     This looks for the first occurrence of "Fred" in $FLINE (the current input
  5326.     line).  If $FLINE contains "Hello Fred!", the command will set the variable
  5327.     x to "7", since "Fred" starts in the seventh character position.
  5328.     
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.                                                                              88
  5335.     ---------------------------
  5336.     Using a Single Decapsulator
  5337.     ---------------------------
  5338.     
  5339.     Sometimes  you don't want to find the FIRST occurrence, but the second,
  5340.     third, and so on.  You can use a single decapsulator (see "The Parse
  5341.     Command") to specify this.  For example:
  5342.     
  5343.     SET      z = "This is the way to demonstrate the FINDPOSN command"
  5344.     FINDPOSN x z "the"
  5345.     FINDPOSN y z "2*the"
  5346.     
  5347.     The first FINDPOSN command finds the first occurrence of "the", using a
  5348.     plain string, so it sets the variable x to "9", since the first "the"
  5349.     starts in the ninth position.
  5350.     
  5351.     The second FINDPOSN command uses a decapsulator with the occurrence number
  5352.     "2*", which means "look for the second occurrence".  Thus, it sets the
  5353.     variable y to "32", since the second "the" occurs in that position.
  5354.     
  5355.     Incidentally, the first FINDPOSN could also have been written this way:
  5356.     
  5357.     FINDPOSN x z "1*the"
  5358.     
  5359.     which is another way of saying, "Look for the first occurrence".  However,
  5360.     if no occurrence number is specified, FINDPOSN assumes you are looking for
  5361.     the first occurrence.
  5362.     
  5363.     ----------------------------
  5364.     The Encapsulated String Find
  5365.     ----------------------------
  5366.     
  5367.     NOTE:  The Encapsulated String Find is very similar to the PARSE command.
  5368.            If you do not find the following discussion sufficiently
  5369.            instructive, you can gain some additional insight by reading the
  5370.            section of this manual entitled "The Parse Command".
  5371.     
  5372.     The Encapsulated String Find looks for a string that is encapsulated by
  5373.     (i.e. located between) two other strings.  This is useful if your input
  5374.     data contains text that is surrounded by delimiters.  One common example is
  5375.     the "comma-delimited" file (see "Why You Need Parse-O-Matic -- An Example"
  5376.     for a sample).  Here is another situation where data is surrounded by
  5377.     delimiters:
  5378.     
  5379.     |Mouse |Gazelle|Mouse  |Elephant|
  5380.     |Dog   |Giraffe|Elk    |Mongoose|
  5381.     |Monkey|Snake  |Caribou|Trout   |
  5382.     
  5383.     One can imagine an application that would create tabular data like this --
  5384.     cleverly (but annoyingly) reducing the column widths to the minimum.  This
  5385.     would make the column starting and ending positions unpredictable.
  5386.     
  5387.  
  5388.  
  5389.                                                                              89
  5390.     You could use the PARSE command to obtain values from each column, but if
  5391.     you have a lot of data, it would be more efficient to determine the
  5392.     starting and ending positions at the outset.
  5393.     
  5394.     Let's say you wanted to extract the third column.  You could set up your
  5395.     POM file like this:
  5396.     
  5397.     BEGIN startposn = ""
  5398.       FINDPOSN startposn $FLINE "3*|" "4*|" "XS"
  5399.       FINDPOSN endposn   $FLINE "3*|" "4*|" "XE"
  5400.       HALT     startposn = "0" "Missing delimiter!"
  5401.     END
  5402.     COPY animal $FLINE startposn endposn
  5403.     OUTEND |{animal}
  5404.     
  5405.     The lines between the BEGIN and END are run only once for the entire
  5406.     parsing job, since they set the startposn variable to something other than
  5407.     a null ("") string.  (See "Uninitialized and Persistent Variables")
  5408.     
  5409.     The first FINDPOSN command uses the decapsulators "3*|" and "4*|" to locate
  5410.     the text between the third and fourth "|" delimiters, but because of the
  5411.     "XS" control value (described later), startposn is set to the position
  5412.     AFTER the delimiter. (Briefly, "XS" means "exclude the found text, and
  5413.     refer to the starting position of the text that follows it.)  Thus, the
  5414.     variable startposn is set to "12"; "Mouse" starts in the twelfth position.
  5415.     
  5416.     The second FINDPOSN command sets the ending position (endposn) in a similar
  5417.     way.  It finds the third and fourth "|" delimiters, but because of the "XE"
  5418.     control setting, it sets endposn to the position BEFORE the fourth
  5419.     delimiter. (Briefly, "XE" means "exclude the found text, and refer to the
  5420.     ending position of the text that precedes it.)
  5421.     
  5422.     The HALT command is simply a safeguard to ensure that the input data
  5423.     follows the correct format.  If the first FINDPOSN fails to find the
  5424.     third or fourth "|" delimiter, it will set startposn to "0" (meaning "not
  5425.     found").
  5426.     
  5427.     The COPY command copies $FLINE (the current input line) from the starting
  5428.     position (startposn) to the ending position (endposn).  This value is then
  5429.     output by the OUTEND command.
  5430.     
  5431.  
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439.  
  5440.  
  5441.  
  5442.  
  5443.  
  5444.                                                                              90
  5445.     ----------------
  5446.     Control Settings
  5447.     ----------------
  5448.     
  5449.     The control settings give you precise control of the part of the string
  5450.     to which you are referring.  Valid control settings are:
  5451.     
  5452.     SETTING  MEANING
  5453.     -------  -------
  5454.       IS     Include found text and report where the  entire   text starts
  5455.       IE     Include found text and report where the  entire   text ends
  5456.       XS     Exclude found text and report where the delimited text starts
  5457.       XE     Exclude found text and report where the delimited text ends
  5458.     
  5459.     NOTE:  While FINDPOSN greatly resembles the PARSE command, the default
  5460.            control setting is different.  In PARSE, the control setting is
  5461.            assumed to be "X" if it is omitted.  In FINDPOSN, however, the
  5462.            control setting is assumed to be "IS" if it is omitted.
  5463.     
  5464.     Let us assume that the we set the variable z as follows:
  5465.     
  5466.     SET z = "ABzzzCDEFzzzGH"
  5467.     
  5468.     This produces the following results:
  5469.     
  5470.             COMMAND                            VALUE FOR x VARIABLE
  5471.             ---------------------------------  --------------------
  5472.             FINDPOSN x z "1*zzz" "2*zzz" "IS"           "3"
  5473.             FINDPOSN x z "1*zzz" "2*zzz" "XS"           "6"
  5474.             FINDPOSN x z "1*zzz" "2*zzz" "XE"           "9"
  5475.             FINDPOSN x z "1*zzz" "2*zzz" "IE"          "12"
  5476.     
  5477.     The following illustration may make the results easier to understand:
  5478.     
  5479.     +------------------------------------------------------------------------+
  5480.     |                                                                        |
  5481.     | Measuring Scale:             12345678901234                            |
  5482.     |                              --------------                            |
  5483.     |         Command: FINDPOSN x "ABzzzCDEFzzzGH" "zzz" "2*zzz" "<control>" |
  5484.     |                                |  |  |  |                              |
  5485.     |   Control Value:              IS XS XE IE                              |
  5486.     |         Results:               3  6  9 12                              |
  5487.     |                                                                        |
  5488.     +------------------------------------------------------------------------+
  5489.     
  5490.     In the example, the control values have the following specific meanings:
  5491.     
  5492.     "IS" ("Include, Start") = start of entire text (from "1*zzz" to "2*zzz")
  5493.     "XS" ("Exclude, Start") = start of text after  the "from" item ("1*zzz")
  5494.     "XE" ("Exclude, End")   =  end  of text before the  "to"  item ("2*zzz")
  5495.     "IE" ("Include, End")   =  end  of entire text (from "1*zzz" to "2*zzz")
  5496.     
  5497.  
  5498.  
  5499.                                                                              91
  5500.     ------------------
  5501.     Insoluble Searches
  5502.     ------------------
  5503.     
  5504.     FINDPOSN returns "0" (zero) when it can not find a string, or if it is
  5505.     presented with an insoluble dilemma.  Here are some examples:
  5506.     
  5507.     FINDPOSN x "CatDog" "Moose"        <-- "Moose" can not be found
  5508.     FINDPOSN x "ABCDEF" "A" "G"        <-- "G" can not be found
  5509.     FINDPOSN x "ABCDEF" "A" "2*E"      <-- There is no second "E"
  5510.     
  5511.     Here is another insoluble search:
  5512.     
  5513.     FINDPOSN x "ABCDEF" "C" "D" "XS"
  5514.     FINDPOSN x "ABCDEF" "C" "D" "XE"
  5515.     
  5516.     There is nothing between the "from" and "to" delimiters. Since we are
  5517.     excluding the delimiters themselves (with "XS" and "XE" specifications), we
  5518.     can not provide a "start" or "end" value for what we found -- we didn't
  5519.     find anything!  Hence, we have nothing for which to to return a starting or
  5520.     ending position.
  5521.     
  5522.     ------------------
  5523.     Null Decapsulators
  5524.     ------------------
  5525.     
  5526.     Consider these next two commands:
  5527.     
  5528.     FINDPOSN x "ABCDEF" "F" "" "XS"
  5529.     FINDPOSN x "ABCDEF" "F" "" "XE"
  5530.     
  5531.     What comes between "F" and the end of the string?  Bear in mind, however,
  5532.     that when you use a null ("") to mean "the last character", it is not
  5533.     excluded (see "The Null Decapsulator" in the section entitled "The Parse
  5534.     Command", for a discussion).  Thus, the two FINDPOSN commands "find" the
  5535.     final character "F", and both return "6".
  5536.     
  5537.     These both return "6" because the "F" is both the starting and ending
  5538.     position of what we found, and we included (rather than excluded) the
  5539.     starting and ending delimiters ("F" and the last character, respectively).
  5540.     
  5541.     Similarly, the following commands return a "1":
  5542.     
  5543.     FINDPOSN x "ABCDEF" "" "A" "XS"
  5544.     FINDPOSN x "ABCDEF" "" "A" "XE"
  5545.     
  5546.     Even though there is nothing between "A" and "the first character", the
  5547.     first character is not excluded, since we are using a null decapsulator.
  5548.     As a result, we find the string "A" and return its position, which is "1".
  5549.     
  5550.  
  5551.  
  5552.  
  5553.  
  5554.                                                                              92
  5555.     ---------------------
  5556.     Finding The Last Word
  5557.     ---------------------
  5558.     
  5559.     One common use for FINDPOSN is to find the last occurence of a word in a
  5560.     line of text.  Consider the following lines:
  5561.     
  5562.     SET       z = "Parse-O-Matic is a fine product!"
  5563.     FINDPOSN  x z ">* " "" "XS"
  5564.     
  5565.     This will set the x variable to 25 (the position of the final word).  The
  5566.     command looks for the last "space" character (which is in position 24),
  5567.     then (because of the "XS" control) returns the position of the character
  5568.     following it.
  5569.     
  5570.     ---------------
  5571.     Who Needs This?
  5572.     ---------------
  5573.     
  5574.     At this point, you may be wondering, "Why do I need to have this kind of
  5575.     precise control?"  Well, in most cases you don't, so you will tend to use
  5576.     the "Plain String Find" (described earlier).  However, certain complex
  5577.     parsing applications demand that you make a distinction between the text
  5578.     that encapsulated a piece of text, and the encapsulated text itself.  When
  5579.     faced with this kind of task, you will see that Parse-O-Matic's FINDPOSN
  5580.     command lets you accomplish in one line what would take dozens of lines in
  5581.     a traditional programming language.
  5582.     
  5583.                                 --------------------
  5584.                                 The SCANPOSN Command
  5585.                                 --------------------
  5586.     
  5587.     FORMAT:        SCANPOSN var1 var2 value1 value2 [value3]
  5588.                             :    :    :      :        :
  5589.     MEANING:                from to   source scanlist control
  5590.     
  5591.     PURPOSE:       SCANPOSN searches the source value for one of the scanterms
  5592.                    in the scanlist (see "Terminology", below).  SCANPOSN finds
  5593.                    out which scanterm provides the best match, then returns the
  5594.                    "from" (starting) and "to" (ending) positions of that
  5595.                    scanterm in the source value.
  5596.     
  5597.     TERMINOLOGY:   scanterm  An item in a scanlist; one of the things you are
  5598.                              searching the source value for.
  5599.                    scanlist  A list of scanterms.  Here is an example of a
  5600.                              scanlist:  "/Mr/Mrs/Ms"
  5601.     
  5602.     PARAMETERS:    var1   is the variable that will contain the starting
  5603.                           position if one of the scanterms is found (e.g. "2"
  5604.                           means it was found in the second position of value1;
  5605.                           "0" means SCANPOSN did not find any of the scanterms)
  5606.                    var2   is the variable that will contain the ending position
  5607.                           if one of the scanterms is found
  5608.  
  5609.                                                                              93
  5610.                    value1 is the source string -- the string being searched
  5611.                    value2 is the scanlist (see "Terminology", above)
  5612.                    value3 is the optional control string
  5613.     
  5614.     DEFAULTS:      value3 = "I" (i.e. Ignore case)
  5615.     
  5616.     ALTERNATIVES:  The FINDPOSN command
  5617.     
  5618.     A common requirement in parsing is to find out if one of several strings can
  5619.     be found in another string.  For example, you might want to find out if a
  5620.     name starts with a "salutation" (Mr., Mrs., Ms.).  You can do this by looping
  5621.     through the various strings and comparing each one, but SCANPOSN lets you do
  5622.     all this with a single command.
  5623.     
  5624.     For example, to search for a salutation in a string:
  5625.     
  5626.     SCANPOSN from to $FLINE "/Mr./Mrs./Miss/Ms."
  5627.     
  5628.     If $FLINE (the line just read from the input file) contains one of the
  5629.     scanterms in the scanlist, SCANPOSN will set the "from" and "to" variables.
  5630.     Thus, if $FLINE contains "Ms. Mary Jones", the "from" variable is set to "1"
  5631.     and the "to" variable is set to "3" (since "Ms." goes from positions 1 to 3
  5632.     in $FLINE).
  5633.     
  5634.     If none of the scanterms is found, the "from" variable is set to "0".  Thus,
  5635.     if $FLINE contains "John Smith", no salutation is found, and the SCANPOSN
  5636.     command shown above will set the "from" variable to "0".
  5637.     
  5638.     ------------
  5639.     The Scanlist
  5640.     ------------
  5641.     
  5642.     The scanlist can contain one or more scanterms.  The FIRST character in the
  5643.     scanlist is interpreted as the delimiter (separator) for the scanterms.
  5644.     Thus, the following scanlists are all valid:
  5645.     
  5646.     "/Mr./Mrs./Miss/Ms."                          <-- Delimiter is:   /
  5647.     "xMr.xMrs.xMissxMs."                          <-- Delimiter is:   x
  5648.     "@Library@School@Gymnasium@Clinic/Hospital"   <-- Delimiter is:   @
  5649.     "/Cow"                                        <-- Delimiter is:   /
  5650.     
  5651.     The first example ("/Mr./Mrs./Miss/Ms.") has already been demonstrated.  The
  5652.     second example uses the letter "x" as a delimiter.  This would cause a
  5653.     problem if one of the scanterms contained an "x", since it would be treated
  5654.     as TWO scanterms.  For example:
  5655.     
  5656.     "xJohnxTrixiexFred"
  5657.     
  5658.     The name "Trixie" contains an "x", so it would be broken down into two
  5659.     scanterms ("Tri" and "ie").  You should always choose a scanlist delimiter
  5660.     that does not appear in the list of scanterms.
  5661.     
  5662.  
  5663.  
  5664.                                                                              94
  5665.     ----------------------
  5666.     Accomodating Variation
  5667.     ----------------------
  5668.     
  5669.     When you design a scanlist, you should take into account the possibility
  5670.     that the input might contain strange variations.  Consider this command:
  5671.     
  5672.     SCANPOSN x y "Mr John Smith" "/Mr./Mrs./Ms."
  5673.     
  5674.     This will set the x variable to "0" because the "Mr" is followed by a space,
  5675.     not a period.  A more "forgiving" command would be:
  5676.     
  5677.     SCANPOSN x y "Mr John Smith" "/Mr./Mrs./Ms./Mr /Mrs /Ms "
  5678.     
  5679.     This would successfully locate the "Mr " string, and set x to "1" and y to
  5680.     "3". (The "3" points to the space.)
  5681.     
  5682.     ------------------------------
  5683.     Handling Prefixes and Suffixes
  5684.     ------------------------------
  5685.     
  5686.     When designing a scanlist, you should consider that a scanterm might be
  5687.     part of a word.  For example:
  5688.     
  5689.     SCANPOSN x y "Mississipi Sue" "/MR./MRS./MISS/MS."
  5690.     
  5691.     This will find the "Miss" in Mississippi, even though this is not part of
  5692.     a salutation.  A more appropriate command would be:
  5693.     
  5694.     SCANPOSN x y "Mississipi Sue" "/MR./MRS./MISS /MS."
  5695.     
  5696.     The space after "Miss" in the scanlist ensures that if it is found, it will
  5697.     be separate from any word following it.
  5698.     
  5699.     The trailing space is not necessary for the scanterm "MR.", since no word
  5700.     contains a period.  However, if you do include spaces after the periods
  5701.     (as in "/MR. /MRS. /MISS /MS. ") it may simplify your subsequent parsing
  5702.     operations.
  5703.     
  5704.     You must also take suffixes into account.  For example:
  5705.     
  5706.     SCANPOSN x y "Zinc Enterprises" "/INC/CO/ENTERPRISES"
  5707.     
  5708.     This will find the "inc" in "Zinc".  You can add a space in front of each
  5709.     scanterm to ensure that it is separated from any other word:
  5710.     
  5711.     SCANPOSN x y "Zinc Enterprises" "/ INC/ CO/ ENTERPRISES"
  5712.     
  5713.     You may be tempted to put spaces on both sides of a word, to handle both
  5714.     prefixes and suffixes.  However, consider this example:
  5715.     
  5716.     SCANPOSN x y "Wazoo Inc" "/ INC / CO / ENTERPRISES "
  5717.     
  5718.  
  5719.                                                                              95
  5720.     None of the scanterms is found, because the "Inc" in the source string
  5721.     does not end in a space.  You can address this kind of problem with the
  5722.     control settings (described next).
  5723.     
  5724.     ----------------------
  5725.     Controlling the Search
  5726.     ----------------------
  5727.     
  5728.     Unless otherwise instructed, SCANPOSN will find the first scanterm that
  5729.     appears anywhere in the source string, and return its start and end
  5730.     positions.  You can modify this behaviour by using the optional control
  5731.     parameter (value3).
  5732.     
  5733.     The control parameter contains one or more characters, each of which has
  5734.     a special meaning.
  5735.     
  5736.     CHARACTER   MEANING
  5737.     ---------   -------
  5738.        <        Find the leftmost match
  5739.        >        Find the rightmost match
  5740.        I        Ignore case (e.g. Xyz matches XYZ)
  5741.        M        Match case (e.g. Xyz does not match XYZ)
  5742.     
  5743.     Here are some valid control settings:
  5744.     
  5745.     SETTING   MEANING
  5746.     -------   -------
  5747.      "<M"     Find the leftmost match, which much match case
  5748.      "<I"     Find the leftmost match, ignoring case
  5749.      ">M"     Find the rightmost match, which must match case
  5750.      "M"      Find any match, but the case must be the same
  5751.     
  5752.     NOTES:  If neither "I" nor "M" are specified, SCANPOSN assumes "I".
  5753.             If neither "<" nor ">" are specified, SCANPOSN does a "Find-Any"
  5754.             search (explained below).
  5755.     
  5756.     -----------------------------
  5757.     Leftmost, Rightmost, Find-Any
  5758.     -----------------------------
  5759.     
  5760.     The ">" (rightmost) control setting tells SCANPOSN to find the scanterm that
  5761.     has the highest "to" value with the lowest "from" value.  This means that
  5762.     ALL of the scanterms are evaluated.  Consider this command:
  5763.     
  5764.     SCANPOSN x y "SHREWxxxCATxxxMOUSExxx" "/CAT/DOGGY/MOUSE/ELK" ">"
  5765.     
  5766.     SCANPOSN finds "CAT", but continues looking to see if there are any better
  5767.     matches to the right.  Eventually it finds MOUSE and sets x to "15" and y
  5768.     to "19" (pointing at "MOUSE").
  5769.     
  5770.     If you use the "<" (leftmost) parameter, SCANPOSN will check all the
  5771.     scanterms to find out which one has the lowest "from" position with the
  5772.     highest "to" value.
  5773.  
  5774.                                                                              96
  5775.     SCANPOSN x y "SHREWxxxCATxxxMOUSExxx" "/CAT/DOGGY/MOUSE/ELK" "<"
  5776.     
  5777.     This will set x to "9" and y to "11" (pointing at "CAT").
  5778.     
  5779.     If you do not specify "<" or ">", SCANPOSN finds the first scanterm it can,
  5780.     and ignores the rest.
  5781.     
  5782.     SCANPOSN x y "SHREWxxxCATxxxMOUSExxx" "/CAT/DOGGY/MOUSE/ELK"
  5783.     
  5784.     The first scanterm is "CAT", and this can be found at positions 9 to 11.
  5785.     SCANPOSN will return those values, and ignore the rest of the scanterms.
  5786.     
  5787.     The absence of a "<" or ">" is known as a "Find-Any" search.  You can use
  5788.     this if you want to know if one of the scanterms appears in the source
  5789.     string, but you are not interested in finding out which one.
  5790.     
  5791.     ------------------------
  5792.     The Best Match Principle
  5793.     ------------------------
  5794.     
  5795.     NOTE:  The "Best Match" principle does not apply to the "Find-Any" search.
  5796.            It applies only to the Leftmost ("<") and Rightmost (">") searches.
  5797.     
  5798.     To use the SCANPOSN command effectively, you must understand the concept of
  5799.     "the best match".  This can be illustrated with an example:
  5800.     
  5801.     SCANPOSN x y "MegaWhizco International" "/CO/WHIZCO/MEGAWHIZ" ">"
  5802.     
  5803.     The SCANPOSN command finds the scanterm CO at positions 5 to 6.  However, it
  5804.     continues looking for an even better match.
  5805.     
  5806.     It finds that WHIZCO is just as far to the right (i.e. it ends at position
  5807.     6), but has a lower starting position.  This makes it a "better" match.
  5808.     
  5809.     The next scanterm (MEGAWHIZ) has a lower starting position, but its ending
  5810.     position is not as good (i.e. not as far to the right).  It is rejected
  5811.     because we are looking for the rightmost string.
  5812.     
  5813.     As a result, SCANPOSN will set x to "1" and y to "6".
  5814.     
  5815.     In other words, when SCANPOSN is looking for the rightmost scanterm, it will
  5816.     first identify the "found" scanterms which have the highest ending position,
  5817.     and then choose the longest one.
  5818.     
  5819.     Here is an example using a leftmost search:
  5820.     
  5821.     SCANPOSN x y "Our catalog is enclosed" "CAT/MOOSE/CATALOG/DOG" "<"
  5822.     
  5823.     The SCANPOSN finds CAT at positions 5 to 7, but as it continues checking
  5824.     the scanterms, it finds that CATALOG is just as far to the left (i.e. it
  5825.     starts at position 5), but it is a better match since it has a higher ending
  5826.     position.
  5827.     
  5828.  
  5829.                                                                              97
  5830.     As a result, SCANPOSN will set x to "5" and y to "11".
  5831.     
  5832.     The "Best Match" principle does not affect "Find-Any" searches.  For
  5833.     example:
  5834.     
  5835.     SCANPOSN x y "Our catalog is enclosed" "CAT/MOOSE/CATALOG/DOG"
  5836.     
  5837.     This sets x to "5" and y to "7".  Since this is a "Find-Any" search (i.e.
  5838.     neither "<" nor ">" are specified in the control settings), SCANPOSN stops
  5839.     looking as soon as it has found a match.
  5840.     
  5841.     When doing a Find-Any search, you can not be sure if any of the other scan
  5842.     terms appear in the source string.  For example:
  5843.     
  5844.     SCANPOSN x y "Our cat and dog are upstairs" "CAT/DOG"
  5845.     
  5846.     This will find CAT and stop looking for additional matches.  If you change
  5847.     the order of the scanlist, you will get different values:
  5848.     
  5849.     SCANPOSN x y "Our cat and dog are upstairs" "DOG/CAT"
  5850.     
  5851.     Thus, a Find-Any search is useful only for detecting if one of the scanterms
  5852.     appears in the source string.  After doing a Find-Any search, you can check
  5853.     if the "from" value is "0" (meaning no scanterms were found).  If it is not
  5854.     "0", it means one of the terms WAS found.  For example:
  5855.     
  5856.     SET      source   = "Our cat catalog is enclosed"
  5857.     SET      scanlist = "CATALOG/MOOSE/CAT/DOG"
  5858.     SCANPOSN from to source scanlist
  5859.     BEGIN    from = "0"
  5860.       OUTEND  |None of the scanterms appeared in the string {source}
  5861.     ELSE
  5862.       OUTEND  |At least one of the scanterms appears in the string {source}
  5863.     END
  5864.     
  5865.     
  5866.     
  5867.  
  5868.  
  5869.  
  5870.  
  5871.  
  5872.  
  5873.  
  5874.  
  5875.  
  5876.  
  5877.  
  5878.  
  5879.  
  5880.  
  5881.  
  5882.  
  5883.  
  5884.                                                                              98
  5885.     ============================================================================
  5886.                                    DATE COMMANDS
  5887.     ============================================================================
  5888.     
  5889.                                  ------------------
  5890.                                  General Discussion
  5891.                                  ------------------
  5892.     
  5893.     Parse-O-Matic's date-oriented commands provide you with a convenient way to
  5894.     work with dates.  While you can accomplish the same thing using other
  5895.     Parse-O-Matic commands (LOOKUP, PAD etc.), the date functions are optimized
  5896.     for speed, so if your parsing job does a lot of date-format conversions, it
  5897.     will run faster.
  5898.     
  5899.     --------------------
  5900.     The POMDATE.CFG File
  5901.     --------------------
  5902.     
  5903.     When a date command is first executed, Parse-O-Matic reads in a file named
  5904.     POMDATE.CFG.  (The method by which Parse-O-Matic finds the file is
  5905.     discussed in the section "How Parse-O-Matic Searches for a File".)
  5906.     
  5907.     POMDATE.CFG is a self-documenting text file that contains the default
  5908.     date format string (explained later), and the names of the twelve months.
  5909.     You can edit this file with a standard text editor, or a word-processor in
  5910.     "generic text" mode.
  5911.     
  5912.     As originally supplied with Parse-O-Matic, the default date format string
  5913.     is "?y/?n/?d", which produces YY/MM/DD dates (e.g. July 1 1998 becomes
  5914.     98/07/01). You can change this to reflect your own preference.
  5915.     
  5916.     If you are parsing data in a language other than English, you can also
  5917.     change the names of the months.
  5918.     
  5919.     ------------
  5920.     Date Formats
  5921.     ------------
  5922.     
  5923.     A date format is a sequence of characters that briefly describes the
  5924.     appearance of a date.  For example, the format "Y-T-?n" describes a
  5925.     year/month/day format that looks like this:  1998-JULY-02
  5926.     
  5927.     The following characters have a special meaning in the date format
  5928.     string:  d M m n T t Y y ?
  5929.     
  5930.     For these special characters, uppercase and lowercase are important.
  5931.     For example, "T" is not the same as "t".
  5932.     
  5933.     All characters other than the special characters are interpreted "as-is",
  5934.     and are included in the final date string.
  5935.     
  5936.  
  5937.  
  5938.  
  5939.                                                                              99
  5940.     The following table explains the meaning of the special characters used
  5941.     to specify year, month and day, using the date July 2, 1998 for the
  5942.     examples:
  5943.     
  5944.          CHAR  MEANING                     SAMPLE FORMAT  SAMPLE RESULT
  5945.          ----  --------------------------  -------------  -------------
  5946.           Y    4-digit year                d-m-Y          2-Jul-1998
  5947.           y    1- or 2-digit year          d-m-y          2-Jul-98
  5948.           n    1- or 2-digit month         d/n/y          2/7/98
  5949.           m    3-letter month              d/m/y          2/Jul/98
  5950.           M    3-letter month (uppercase)  d M y          2 JUL 98
  5951.           t    Month                       t d, Y         July 2, 1998
  5952.           T    Month (uppercase)           T d Y          JULY 2 1998
  5953.           d    Day                         y/m/d          98/7/2
  5954.     
  5955.     The ? character can be used in the date format to pad out one-digit
  5956.     values to two digits.  The following table uses the date February 3, 2001
  5957.     for the examples:
  5958.     
  5959.                        SAMPLE DATE FORMAT   SAMPLE RESULT
  5960.                        ------------------   -------------
  5961.                        y-?n-?d              1-02-03
  5962.                        ?y/m/?d              01/Feb/03
  5963.                        ?n/?d Y              02/01 2001
  5964.                        t '?y                February '01
  5965.     
  5966.     As the last example shows, it is not necessary to use month, day and year;
  5967.     you can omit any item to obtain an abbreviated date.
  5968.     
  5969.  
  5970.  
  5971.  
  5972.  
  5973.  
  5974.  
  5975.  
  5976.  
  5977.  
  5978.  
  5979.  
  5980.  
  5981.  
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.  
  5988.  
  5989.  
  5990.  
  5991.  
  5992.  
  5993.  
  5994.                                                                             100
  5995.                                  -----------------
  5996.                                  The TODAY Command
  5997.                                  -----------------
  5998.     
  5999.     FORMAT:        TODAY var1 [value1]
  6000.     
  6001.     PURPOSE:       The TODAY command sets a variable (var1) to today's date, in
  6002.                    a variety of formats.
  6003.     
  6004.     DEFAULTS:      If value1 is not specified, TODAY uses the default date
  6005.                    format, which is specified in the file POMDATE.CFG.
  6006.     
  6007.     NOTES:         For a discussion of date formats (including the default date
  6008.                    format), see the "General Discussion" section at the
  6009.                    beginning of this chapter.
  6010.     
  6011.     SEE ALSO:      "The Date Command"
  6012.     
  6013.     Assuming today's date is July 1 1998, here are some examples:
  6014.     
  6015.                COMMAND              THE VARIABLE xyz IS SET TO...
  6016.                -------------------  -----------------------------
  6017.                TODAY xyz            The default date format
  6018.                TODAY xyz ""         The default date format
  6019.                TODAY xyz "Y-M-?d"   1998-JUL-01
  6020.                TODAY xyz "t d Y"    July 1 1998
  6021.                TODAY xyz "t 'y"     July '98
  6022.     
  6023.     As the last example shows, it is not necessary to use month, day and year;
  6024.     you can omit any item to obtain an abbreviated date.
  6025.     
  6026.  
  6027.  
  6028.  
  6029.  
  6030.  
  6031.  
  6032.  
  6033.  
  6034.  
  6035.  
  6036.  
  6037.  
  6038.  
  6039.  
  6040.  
  6041.  
  6042.  
  6043.  
  6044.  
  6045.  
  6046.  
  6047.  
  6048.  
  6049.                                                                             101
  6050.                                   ----------------
  6051.                                   The DATE Command
  6052.                                   ----------------
  6053.     
  6054.     FORMAT:        DATE var1 value1 value2 value3 [value4]
  6055.     
  6056.     PURPOSE:       The DATE command sets a variable (var1) to given year
  6057.                    (value1), month (value2) and day (value3), or a subset of
  6058.                    these items, in a variety of formats, as specified by the
  6059.                    format string (value4).
  6060.     
  6061.     PARAMETERS:    var1   is the variable being set
  6062.                    value1 is the year (e.g. "1998" or "98")
  6063.                    value2 is the month (e.g. "1" = January)
  6064.                    value3 is the day (1 to 31)
  6065.                    value4 is the date format
  6066.     
  6067.     NUMERICS:      Tabs, spaces and commas are stripped from value1, 2 and 3
  6068.     
  6069.     DEFAULTS:      If value4 is omitted, DATE uses the default date format,
  6070.                    which is specified in the file POMDATE.CFG.
  6071.     
  6072.     NOTES:         For a discussion of date formats (including the default date
  6073.                    format), see the "General Discussion" section at the
  6074.                    beginning of this chapter.
  6075.     
  6076.     SEE ALSO:      "The Today Command"
  6077.     
  6078.     Assuming the date being set is July 1 1998, here are some examples:
  6079.     
  6080.     COMMAND                             THE VARIABLE xyz IS SET TO...
  6081.     ----------------------------------  -----------------------------
  6082.     DATE xyz "98"   "07" "01"           The default date format
  6083.     DATE xyz "1998" "07" "01" ""        The default date format
  6084.     DATE xyz "98"    "7"  "1" "Y-M-?d"  1998-JUL-01
  6085.     DATE xyz "98"   "07" "01" "t d Y"   July 1 1998
  6086.     DATE xyz "98"    "7" "01" "t 'y"    July '98
  6087.     DATE xyz "98"    "7"   "" "t 'y"    July '98
  6088.     
  6089.     As the last two examples show, it is not necessary to use month, day and
  6090.     year; you can omit any item to obtain an abbreviated date.
  6091.     
  6092.     If a date is outside a valid range, Parse-O-Matic halts with an error.
  6093.     Acceptable value ranges are:  Year 0 to 9999; Month 1 to 12; Day 1 to 31
  6094.     
  6095.     If the year is between 0 and 99, Parse-O-Matic makes the following
  6096.     assumptions:
  6097.     
  6098.     - If the number is between 80 and 99, it means 1980 to 1999
  6099.     - If the number is between  0 and 79, it means 2000 to 2079
  6100.     
  6101.     Parse-O-Matic does not check that a date is "possible", so you could set
  6102.     a date to "February 31, 2001", even though February never has 31 days.
  6103.  
  6104.                                                                             102
  6105.                                --------------------
  6106.                                The MONTHNUM Command
  6107.                                --------------------
  6108.     
  6109.     FORMAT:        MONTHNUM var1 value1
  6110.     
  6111.     PURPOSE:       The MONTHNUM command sets the month number of a given month.
  6112.     
  6113.     ALTERNATIVES:  The LOOKUP command
  6114.     
  6115.     Here is an example of the MONTHNUM command:
  6116.     
  6117.     MONTHNUM xyz "February"
  6118.     
  6119.     This will set the variable xyz to "2".
  6120.     
  6121.     The comparison is performed on the basis of the number of characters
  6122.     available, without regard to case, so the following would also work:
  6123.     
  6124.     MONTHNUM xyz "FEB"
  6125.     
  6126.     If the result is ambiguous, Parse-O-Matic returns the first match.  For
  6127.     example:
  6128.     
  6129.     MONTHNUM xyz "JU"
  6130.     
  6131.     This will set xyz to "6", although it could refer to either June or July.
  6132.     
  6133.     If MONTHNUM can not find a match, it will return a null ("") string.
  6134.     For example:
  6135.     
  6136.     MONTHNUM xyz "ZZZ"
  6137.     
  6138.     Since no month starts with "ZZZ", this will set xyz to "".
  6139.     
  6140.     If you are writing a Parse-O-Matic application that will be run in several
  6141.     languages (using different POMDATE.CFG files), you should carefully study
  6142.     the names of the months in each language to avoid problems.  In English, it
  6143.     is always sufficient to provide the first three letters.  In French,
  6144.     however, you need at least four letters, to distinguish between "Juin"
  6145.     (June) and "Juillet" (July).
  6146.     
  6147.     Parse-O-Matic can use only one POMDATE.CFG file at a time, so the MONTHNUM
  6148.     command can not be used to translate month names from one language to
  6149.     another.  You can, however, accomplish the same thing with the LOOKUP
  6150.     command.
  6151.     
  6152.  
  6153.  
  6154.  
  6155.  
  6156.  
  6157.  
  6158.  
  6159.                                                                             103
  6160.                                 --------------------
  6161.                                 The ZERODATE Command
  6162.                                 --------------------
  6163.     
  6164.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  6165.     
  6166.     FORMAT:        ZERODATE value1 value2 value3
  6167.     
  6168.     PURPOSE:       Specifies "day zero" for the date serial number used by the
  6169.                    MAKETEXT command when it uses the DATE predefined data type.
  6170.     
  6171.     PARAMETERS:    value1 is the year  (e.g. "1900")
  6172.                    value2 is the month (e.g. "12" for December)
  6173.                    value3 is the day   (e.g. "5")
  6174.     
  6175.     NUMERICS:      Tabs, spaces and commas are stripped from value1, 2 and 3
  6176.     
  6177.     DEFAULTS:      If the ZERODATE command is omitted, the zero date is assumed
  6178.                    to be Jan. 1, 1753 (equivalent to ZERODATE "1753" "1" "1").
  6179.     
  6180.     SEE ALSO:      "The MakeText Command" and "Predefined Data Types"
  6181.     
  6182.     A "date serial number" is a common method of representing a date in a data
  6183.     file.  It works by counting the number of days since a given date, taking
  6184.     into account the extra days for leap years.
  6185.     
  6186.     Leap years occur in every year that is divisible by four, with the
  6187.     exception of century years -- unless they are divisible by 400. Thus, 1900
  6188.     is not a leap year, but 2000 is.
  6189.     
  6190.     The ZERODATE command specifies "Day 0".  For example, if you specify
  6191.     ZERODATE "1918" "11" "11" (November 11, 1918), you get the following:
  6192.     
  6193.                      DATE               DATE SERIAL NUMBER
  6194.                      -----------------  ------------------
  6195.                      November  9, 1918          -2
  6196.                      November 10, 1918          -1
  6197.                      November 11, 1918           0
  6198.                      November 12, 1918           1
  6199.                      November 13, 1918           2
  6200.     
  6201.     ... and so on.  Most programs set the zero date far enough back that
  6202.     negative numbers are not encountered in normal usage.
  6203.     
  6204.     ZERODATE will not accept a starting year before "1753", which was the first
  6205.     full year that most of the Western world started using the Gregorian
  6206.     calendar.
  6207.     
  6208.     
  6209.     
  6210.  
  6211.  
  6212.  
  6213.  
  6214.                                                                             104
  6215.     ============================================================================
  6216.                                 CALCULATION COMMANDS
  6217.     ============================================================================
  6218.     
  6219.                                   ----------------
  6220.                                   The CALC Command
  6221.                                   ----------------
  6222.     
  6223.     FORMAT:        CALC var1 value1 operation value2
  6224.     
  6225.     PURPOSE:       The CALC command performs an integer arithmetic operation on
  6226.                    the two values and assigns the answer to var1.
  6227.     
  6228.     NUMERICS:      Tabs, spaces and commas are stripped from value1 and value2
  6229.     
  6230.     ALTERNATIVES:  The CALCREAL command
  6231.     
  6232.     SEE ALSO:      "Inline Incrementing and Decrementing"
  6233.     
  6234.     Integer arithmetic refers to whole numbers.  1, 10 and 10000 are integers,
  6235.     while 2.0, 3.14159 and 98.5 are not.
  6236.     
  6237.     Let's say your input file looks like this:
  6238.     
  6239.     DESCRIPTION      UNITS SOLD    UNIT PRICE
  6240.     ---------------- ----------    ----------
  6241.     Dog collar               15    $     3.00
  6242.     Cat collar               25    $     2.50
  6243.     Cat caller                3    $     7.25
  6244.     Birdie num-nums       1,305    $     6.25
  6245.     ---------------- ----------    ----------
  6246.     End of Data
  6247.     :                :        :     :       :
  6248.     :                :        :     :       :    (Column positions)
  6249.     1               18       27    33      41
  6250.     
  6251.     You can find out the total number of units sold (of all types) with the
  6252.     following POM file:
  6253.     
  6254.     IGNORE $FLINE[1 7] = "DESCRIP"
  6255.     IGNORE $FLINE[1 7] = "-------"
  6256.     BEGIN $FLINE = "End of Data"
  6257.       OUTEND |Total units sold = {units}
  6258.     ELSE
  6259.       CALC units = units "+" $FLINE[18 27]
  6260.     END
  6261.     
  6262.     As you can see from the example, all spaces and commas are stripped from
  6263.     the number.  Tab characters (ASCII 09) are also stripped.
  6264.     
  6265.     You will also notice that CALC can not be used for the prices, since they
  6266.     are not integer data.  To add up the prices, you must use the CALCREAL
  6267.     command (see "The CalcReal Command").
  6268.  
  6269.                                                                             105
  6270.     Note in particular that the operation ("+" in this case) is in quotes.  If
  6271.     you omit the quotes, Parse-O-Matic will report an error.
  6272.     
  6273.     The following operations can be performed with CALC:
  6274.     
  6275.             SYMBOL     DESCRIPTION
  6276.             ---------  --------------------------------------------
  6277.             "+"        value1 plus value2
  6278.             "-"        value1 minus value2
  6279.             "*"        value1 times value2
  6280.             "/"        value1 divided by value2 (remainder ignored)
  6281.             "HIGHEST"  the larger number (value1 or value2)
  6282.             "LOWEST"   the smaller number (value1 or value2)
  6283.     
  6284.     Here are some more examples of the CALC command:
  6285.     
  6286.                    COMMAND                           ANSWER
  6287.                    --------------------------------  ------
  6288.                    CALC answer = "12" "/" "4"           "3"
  6289.                    CALC answer = "12" "HIGHEST" "4"    "12"
  6290.                    CALC answer = "12" "LOWEST"  "4"     "4"
  6291.                    CALC answer = "12" "-" "4"           "8"
  6292.                    CALC answer = "12" "+" "4"          "16"
  6293.                    CALC answer = "12" "*" "4"          "48"
  6294.     
  6295.     CALC can handle numbers between -2,147,483,648 and 2,147,483,647.
  6296.     
  6297.                                 --------------------
  6298.                                 The CALCREAL Command
  6299.                                 --------------------
  6300.     
  6301.     FORMAT:        CALCREAL var1 value1 operation value2 [fixed-decimals]
  6302.     
  6303.     PURPOSE:       CALCREAL works the same way as CALC, except that it handles
  6304.                    decimal numbers.
  6305.     
  6306.     NUMERICS:      Tabs, spaces and commas are stripped from value1, value2,
  6307.                    and the "fixed-decimals" value
  6308.     
  6309.     ALTERNATIVES:  The CALC command
  6310.     
  6311.     SEE ALSO:      "The Rounding Command"
  6312.     
  6313.  
  6314.  
  6315.  
  6316.  
  6317.  
  6318.  
  6319.  
  6320.  
  6321.  
  6322.  
  6323.  
  6324.                                                                             106
  6325.     Using the sample data given in the CALC section, you could write the
  6326.     following POM file:
  6327.     
  6328.     IGNORE $FLINE[1 7] = "DESCRIP"
  6329.     IGNORE $FLINE[1 7] = "-------"
  6330.     BEGIN $FLINE = "End of Data"
  6331.       OUTEND |Total units sold = {units}
  6332.       OUTEND |Total value sold = {value}
  6333.     ELSE
  6334.       CALC     units = units "+" $FLINE[18 27]
  6335.       CALCREAL value = value "+" $FLINE[33 41]
  6336.     END
  6337.     
  6338.     CALCREAL can handle values +/- 99,999,999,999, but its accuracy decreases
  6339.     when you are dealing with large numbers, as approximated below:
  6340.     
  6341.     Accurate to 1 decimal place  between +/- 9,999,999,999
  6342.     Accurate to 2 decimal places between +/-   999,999,999
  6343.     Accurate to 3 decimal places between +/-    99,999,999
  6344.     Accurate to 4 decimal places between +/-     9,999,999
  6345.     Accurate to 5 decimal places between +/-       999,999
  6346.     
  6347.     You can specify a fixed number of decimal positions in the answer by using
  6348.     the optional "fixed-decimals" value.  For example:
  6349.     
  6350.     SET z = "3.14159"
  6351.     CALCREAL x = z "+" "0" "2"      <-- This sets x to "3.14"
  6352.     CALCREAL x = z "+" "0" "4"      <-- This sets x to "3.1415"
  6353.     
  6354.     You will notice, in the second example, that no "rounding" takes place.
  6355.     The number is simply truncated at the requested decimal position.
  6356.     
  6357.     Here are some more examples of the CALCREAL command:
  6358.     
  6359.            COMMAND                                           ANSWER
  6360.            -----------------------------------------------  --------
  6361.            CALCREAL answer = "12.0"  "*"        "4.0"  "2"   "48.00"
  6362.            CALCREAL answer = "12.0"  "HIGHEST"  "4.0"  "2"   "12.00"
  6363.            CALCREAL answer =   "12"  "LOWEST      "4"  "1"     "4.0"
  6364.            CALCREAL answer =   "12"  "-"          "4"  "3"   "8.000"
  6365.            CALCREAL answer =   "12"  "+"          "4"  "1"    "16.0"
  6366.            CALCREAL answer =    "7"  "/"          "2"  "2"    "3.50"
  6367.            CALCREAL answer =    "7"  "/"          "2"          "3.5"
  6368.            CALCREAL answer =    "7"  "*"          "2"         "14.0"
  6369.     
  6370.     As shown in the examples, if you do not use the optional fixed-decimal
  6371.     value, calculations are in "floating point".  That is to say, the answer
  6372.     has as many decimal places as necessary.  (Bear in mind the accuracy
  6373.     restrictions mentioned earlier.)  Trailing zeros are removed, unless there
  6374.     are no digits after the decimal point, in which case a 0 is added.
  6375.     
  6376.  
  6377.  
  6378.  
  6379.                                                                             107
  6380.                                 --------------------
  6381.                                 The ROUNDING Command
  6382.                                 --------------------
  6383.     
  6384.     FORMAT:        ROUNDING "Y" or ROUNDING "N"
  6385.     
  6386.     PURPOSE:       Controls rounding of answers given by the CALCREAL command
  6387.                    when it is in "fixed-decimal" mode.
  6388.     
  6389.     PARAMETERS:    ROUNDING "Y" turns on rounding (the default)
  6390.                    ROUNDING "N" turns off rounding
  6391.     
  6392.     ALTERNATIVES:  The CALCREAL command can be used in "floating point" mode,
  6393.                    and you can perform rounding and truncation operations
  6394.                    yourself, within the POM file.
  6395.     
  6396.     Due to the way that real numbers (as opposed to integers) are calculated in
  6397.     binary, CALCREAL can sometimes return unexpected results.  For example:
  6398.     
  6399.     CALCREAL x = "400.00" "-" "390.60"
  6400.     
  6401.     produces the answer "9.399999" rather than the expected answer of "9.4".
  6402.     
  6403.     This discrepancy is due to the nature of real-mode calculations in binary
  6404.     (i.e. inside the computer). The answer is actually very close indeed to the
  6405.     correct answer, yet it could cause problems if you specify the actual number
  6406.     of digits of precision ("fixed-decimals" mode instead of "floating point"
  6407.     mode).  For example:
  6408.     
  6409.     ROUNDING "N"                              <-- This is explained later
  6410.     CALCREAL x = "400.00" "-" "390.60" "2"    <-- 2 digits of precision
  6411.     
  6412.     This sets the x variable to "3.39", which is clearly wrong.  What has
  6413.     happened is that the remaining digits of the floating-point answer were
  6414.     simply truncated (i.e. removed).
  6415.     
  6416.     Normally, Parse-O-Matic's built-in rounding will add a small value
  6417.     appropriate to the number of digits of fixed-decimal precision you have
  6418.     specified:
  6419.     
  6420.                      PRECISION   SAMPLE NUMBER   ROUNDING VALUE
  6421.                      ---------   -------------   --------------
  6422.                          1           9.9            + 0.05
  6423.                          2           9.99           + 0.005
  6424.                          3           9.999          + 0.0005
  6425.     
  6426.     ... and so on.  Thus, CALCREAL "400.00" "-" "390.60" "2" first generates the
  6427.     floating-point answer "9.3999999999", adds "0.005", yielding "9.4049999999".
  6428.     This is then truncated to two digits, yielding "9.40", which is the correct
  6429.     answer.
  6430.     
  6431.  
  6432.  
  6433.  
  6434.                                                                             108
  6435.     You can turn this rounding behaviour off with the following command:
  6436.     
  6437.     ROUNDING "N"
  6438.     
  6439.     You can turn it back on with this command:
  6440.     
  6441.     ROUNDING "Y"
  6442.     
  6443.     By default, rounding is enabled, so unless you explicitly turn it off, there
  6444.     is no need to use the ROUNDING "Y" command.
  6445.     
  6446.     No rounding is performed when CALCREAL is used in "floating-point" mode.
  6447.     
  6448.                                 --------------------
  6449.                                 The CALCBITS Command
  6450.                                 --------------------
  6451.     
  6452.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  6453.     
  6454.     FORMAT:        CALCBITS var1 value1 operation value2
  6455.     
  6456.     PURPOSE:       CALCBITS performs logical operations
  6457.     
  6458.     SEE ALSO:      "The MakeData Command"
  6459.     
  6460.     The CALCBITS command performs "bit-wise" operations on single bytes.  The
  6461.     following operations can be performed with CALCBITS:
  6462.     
  6463.                   SYMBOL     DESCRIPTION
  6464.                   ---------  ---------------------------------
  6465.                   "AND"      value1 AND value2
  6466.                   "OR"       value1 OR  value2
  6467.                   "XOR"      value1 XOR value2
  6468.                   "SHR"      Shift value1 right by value2 bits
  6469.                   "SHL"      Shift value1 left  by value2 bits
  6470.     
  6471.     Let us say you want to strip the high bit from all of the bytes in an input
  6472.     file.  You could accomplish this with the following POM file:
  6473.     
  6474.     CHOP     1-1                    <-- Read the input file one byte at a time
  6475.     CALCBITS z $FLINE "AND" $7F     <-- Remove the high bit from the byte
  6476.     OUT      |{z}                   <-- Send the result to the output file
  6477.     
  6478.     Note that because we are reading the file one byte at a time, $FLINE is
  6479.     always one byte long.  Parse-O-Matic will terminate with an error message
  6480.     if you attempt to use CALCBITS with a value longer than one byte.  Thus,
  6481.     assuming the variable xyz contains "ABCDEF", the following line is valid:
  6482.     
  6483.     CALCBITS answer = xyz[3] "AND" $7F
  6484.     
  6485.  
  6486.  
  6487.  
  6488.  
  6489.                                                                             109
  6490.     However, the following line would not be permitted because it refers to
  6491.     more than one byte:
  6492.     
  6493.     CALCBITS answer = xyz[3 4] "AND" $7F
  6494.     
  6495.     Here are some more examples of the CALCBITS command:
  6496.     
  6497.     COMMAND                           ANSWER   COMMENTS
  6498.     -------------------------------   ------   ------------------------------
  6499.     CALCBITS answer = $FF "AND" $7F     $7F
  6500.     CALCBITS answer = "9" "AND" $39     $39    $39 is the character "9"
  6501.     CALCBITS answer = $F0 "OR"  $0F     $FF
  6502.     CALCBITS answer = $7F "XOR" $08     $77
  6503.     CALCBITS answer = $80 "SHR" $01     $40    $80 = 10000000; $40 = 01000000
  6504.     CALCBITS answer = $01 "SHR" $01     $00    $01 = 00000001; $00 = 00000000
  6505.     CALCBITS answer = $01 "SHL" $01     $02    $01 = 00000001; $02 = 00000010
  6506.     CALCBITS answer = $80 "SHL" $01     $00    $80 = 10000000; $00 = 00000000
  6507.     
  6508.     In most of these examples, we use hex notation (e.g. $01), but you can also
  6509.     use single characters (e.g. "3" which is equivalent to $33) or decimal
  6510.     notation (e.g. #64 which is equivalent to $40).  However, you should always
  6511.     bear in mind that you are working with the underlying bit pattern.  The
  6512.     following lines are NOT equivalent:
  6513.     
  6514.     CALCBITS answer = $7F "SHL" $01         <-- Shifts left one bit
  6515.     CALCBITS answer = $7F "SHL" "1"         <-- This is not the same!
  6516.     
  6517.     The second line interprets "1" as hex $31 (decimal 49).  There is obviously
  6518.     no point in shifting an eight-bit byte 49 positions to the left.
  6519.     
  6520.     
  6521.     
  6522.     
  6523.     
  6524.  
  6525.  
  6526.  
  6527.  
  6528.  
  6529.  
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535.  
  6536.  
  6537.  
  6538.  
  6539.  
  6540.  
  6541.  
  6542.  
  6543.  
  6544.                                                                             110
  6545.     ============================================================================
  6546.                                 INPUT PREPROCESSORS
  6547.     ============================================================================
  6548.     
  6549.                                  -----------------
  6550.                                  The SPLIT Command
  6551.                                  -----------------
  6552.     
  6553.     FORMAT:        SPLIT from-position to-position [,from-pos'n to-pos'n] [...]
  6554.     
  6555.     SEE ALSO:      "The Leftover Technique"
  6556.     
  6557.     IMPORTANT:     This command is analyzed at compile time, which means it can
  6558.                    not be used conditionally (i.e. in a BEGIN/END block).
  6559.     
  6560.     The maximum length of an input line from a text file is 255 characters.  If
  6561.     your input file is wider than that, you must break up the file into
  6562.     manageable chunks, using the SPLIT command.  This command lets you specify
  6563.     the way in which each input line is broken up so that it will look like
  6564.     several SEPARATE lines.
  6565.     
  6566.     For example, if your input lines were up to 300 characters wide, you could
  6567.     specify:
  6568.     
  6569.     SPLIT 1 255, 256 300
  6570.     
  6571.     This breaks up each line as if it was two lines.  (If some of the lines are
  6572.     less than 256 characters, they will still be treated as two lines, although
  6573.     the second line will be null (i.e. empty).)
  6574.     
  6575.     You can specify up to 130 splits (use multiple SPLIT commands if
  6576.     necessary).  With SPLIT, Parse-O-Matic can handle large input records,
  6577.     up to a maximum total length of 32767 characters.
  6578.     
  6579.     The best way of handling SPLIT or CHOPped files is to use a combination of
  6580.     the $SPLIT variable (explained in more detail later) and BEGIN/END.  For
  6581.     example:
  6582.     
  6583.     SPLIT 1 250, 251 300
  6584.     BEGIN $SPLIT = "1"
  6585.       SET a = $FLINE[ 1 10]
  6586.       SET b = $FLINE[11 20]
  6587.     END
  6588.     BEGIN $SPLIT = "2"
  6589.       SET x = $FLINE[ 1 10]
  6590.       SET y = $FLINE[11 20]
  6591.       OUTEND |{a} {b} {x} {y}
  6592.     END
  6593.     
  6594.     This outputs the data which appears (in the input file) in columns 1-10,
  6595.     11-20, 251-260 and 261-280.
  6596.     
  6597.  
  6598.  
  6599.                                                                             111
  6600.     ------------------------------
  6601.     Indicating Actual Input Length
  6602.     ------------------------------
  6603.     
  6604.     The final split must indicate the maximum length of the line.  Thus, if you
  6605.     have a text file with a maximum line length of 275, you still have to
  6606.     indicate this, even if you are only interested in the first 100 characters:
  6607.     
  6608.     SPLIT 1-100, 101-275
  6609.     
  6610.     You could use IGNORE $SPLIT = "2" to get rid of the additional text lines.
  6611.     
  6612.     ---------------------
  6613.     Non-Contiguous Splits
  6614.     ---------------------
  6615.     
  6616.     Your splits do not have to be contiguous.  For example, the following SPLIT
  6617.     command is legal:
  6618.     
  6619.     SPLIT 5 39, 41 100, 247 285
  6620.     
  6621.     The first four characters of each split would be ignored, so your first
  6622.     split would contain only the characters at positions 5 to 39 of the line.
  6623.     Similarly, the second split would contain the 41st through 100th character,
  6624.     and the third split would contain the 247th through 285th character.
  6625.     
  6626.                                   ----------------
  6627.                                   The CHOP Command
  6628.                                   ----------------
  6629.     
  6630.     FORMAT:        CHOP from-position to-position [,from-pos'n to-pos'n] [...]
  6631.                    CHOP 0
  6632.     
  6633.     PURPOSE:       Controls the number of bytes Parse-O-Matic will read from
  6634.                    the input file each time it processes the POM file.
  6635.     
  6636.     SEE ALSO:      "The Get Command"
  6637.     
  6638.     IMPORTANT:     This command is analyzed at compile time, which means it can
  6639.                    not be used conditionally (i.e. in a BEGIN/END block).
  6640.     
  6641.     The CHOP command works the same way as the SPLIT command, with one
  6642.     exception:  it informs Parse-O-Matic that the input is a fixed-record-
  6643.     length file. In other words, it means that the input records are
  6644.     distinguished by having a particular (and exact) length, rather than being
  6645.     separated by end-of-line characters (Carriage Return, Linefeed) as is the
  6646.     case for a standard text file.
  6647.     
  6648.     Thus, if you have an input file containing fixed-length records, each of
  6649.     which is 200 characters wide, you could specify it like this:
  6650.     
  6651.     CHOP 1 200
  6652.     
  6653.  
  6654.                                                                             112
  6655.     If the input record is more than 255 characters, you must break it up into
  6656.     smaller chunks.  For example, if the input record was 300 characters wide,
  6657.     you could break it up like this:
  6658.     
  6659.     CHOP 1 250, 251 300
  6660.     
  6661.     By using CHOP, Parse-O-Matic can handle input records up to 32767
  6662.     characters wide.  You can use the $SPLIT variable to manage your use of
  6663.     CHOP.  See the example in the section describing the SPLIT command.
  6664.     
  6665.     --------------
  6666.     Manual Reading
  6667.     --------------
  6668.     
  6669.     There is a special form of the CHOP command, which looks like this:
  6670.     
  6671.     CHOP 0
  6672.     
  6673.     This tells Parse-O-Matic that you will handle all file reading yourself. In
  6674.     such case, $FLINE is always null.  The only way to get data from the input
  6675.     file is with the GET command.
  6676.     
  6677.     When you use CHOP 0 for manual reading, the MINLEN and READNEXT commands
  6678.     have no meaning.  If you place them in the POM file, they are ignored.
  6679.     
  6680.     
  6681.     
  6682.  
  6683.  
  6684.  
  6685.  
  6686.  
  6687.  
  6688.  
  6689.  
  6690.  
  6691.  
  6692.  
  6693.  
  6694.  
  6695.  
  6696.  
  6697.  
  6698.  
  6699.  
  6700.  
  6701.  
  6702.  
  6703.  
  6704.  
  6705.  
  6706.  
  6707.  
  6708.  
  6709.                                                                             113
  6710.     ============================================================================
  6711.                                   LOOKUP COMMANDS
  6712.     ============================================================================
  6713.     
  6714.                                  ------------------
  6715.                                  The LOOKUP Command
  6716.                                  ------------------
  6717.     
  6718.     FORMAT:        LOOKUP var1 value1
  6719.     
  6720.     PURPOSE:       The LOOKUP command searches for value1 in a text file (the
  6721.                    name of which is specified either by the LOOKFILE command or
  6722.                    the /L startup parameter). When POM finds it, it sets var1
  6723.                    to another value found on the same line.
  6724.     
  6725.     ALTERNATIVES:  The REMAP command
  6726.     
  6727.     Let us suppose you created a text file, named NAMES.TBL, like this:
  6728.     
  6729.     R. REAGAN        Ronald Reagan
  6730.     D. EISENHOWER    Dwight Eisenhower
  6731.     G. BUSH          George Bush
  6732.     B. CLINTON       Bill Clinton
  6733.     :                :
  6734.     Column 1         Column 18
  6735.     
  6736.     This file can be used to look up a name, as in this POM file:
  6737.     
  6738.     LOOKFILE "NAMES.TBL"
  6739.     LOOKCOLS "1" "17" "18" "34"
  6740.     SET      oldname = $FLINE[21 37]
  6741.     TRIM     oldname "R" " "
  6742.     LOOKUP   newname = oldname
  6743.     OUTEND   |{oldname} {newname}
  6744.     
  6745.     The LOOKFILE command specifies the name of the look-up file.  The LOOKCOLS
  6746.     command specifies the starting and end columns for both the "text-to-look-
  6747.     for" field (known as the key field) and the "text-to-get" field (known as
  6748.     the data field).
  6749.     
  6750.     The LOOKUP command will look for oldname in NAMES.TBL.  If oldname is set
  6751.     to "G. BUSH", LOOKUP sets newname to "George Bush".  If, however, oldname
  6752.     is set to "G. WASHINGTON", which doesn't appear in NAMES.TBL, newname
  6753.     is set to "" (that is to say, an empty string).
  6754.     
  6755.  
  6756.  
  6757.  
  6758.  
  6759.  
  6760.  
  6761.  
  6762.  
  6763.  
  6764.                                                                             114
  6765.     -------------
  6766.     Search Method
  6767.     -------------
  6768.     
  6769.     When searching for the key field, LOOKUP compares text according to the
  6770.     length of the string you are looking for.  If your LOOKUP file looks like
  6771.     this:
  6772.     
  6773.         ABCDEF    456
  6774.         ABC       678
  6775.         XYZABC    345
  6776.         XYZ       123
  6777.     
  6778.     then the command LOOKUP x = "XYZ" would match on "XYZABC".  If this search
  6779.     procedure is a problem for you, there are two ways you can deal with it:
  6780.     
  6781.     1)  Pad your search strings before searching, as in this example:
  6782.     
  6783.         PAD     search "R" " " "6"
  6784.         LOOKUP  x = search
  6785.     
  6786.         If the search variable was original set to "XYZ", the PAD command
  6787.         would set it to "XYZ   ", which would not match XYZABC.
  6788.     
  6789.     2)  Put the shorter key fields in the lookup file ahead of the longer
  6790.         ones (of which they are a sub-string), as in this example:
  6791.     
  6792.         ABC       678
  6793.         ABCDEF    456
  6794.         XYZ       123
  6795.         XYZABC    345
  6796.     
  6797.         It is worth pointing out that this look-up file is sorted in
  6798.         ASCII order (whereas the example given earlier was not).  A sorted
  6799.         file can be more efficient, as explained in "The LookSpec Command".
  6800.     
  6801.     -----------
  6802.     Limitations
  6803.     -----------
  6804.     
  6805.     There is no limit to the number of lines that you can put in a look-up
  6806.     file.  However, the more lines there are, the longer it will take to
  6807.     process (because there is more to search).  The maximum length of a line
  6808.     in a look-up file is 255 characters.
  6809.     
  6810.  
  6811.  
  6812.  
  6813.  
  6814.  
  6815.  
  6816.  
  6817.  
  6818.  
  6819.                                                                             115
  6820.     -----------------------
  6821.     Null Lines and Comments
  6822.     -----------------------
  6823.     
  6824.     In the look-up file, null (empty) lines are ignored.  You can also include
  6825.     comments in the file by starting the line with a semi-colon:
  6826.     
  6827.     ; Some of the Presidents of the United States
  6828.     R. REAGAN        Ronald Reagan
  6829.     D. EISENHOWER    Dwight Eisenhower
  6830.     G. BUSH          George Bush
  6831.     
  6832.     The LOOKUP command can be used for more than just names, of course.  You
  6833.     could use it to look up prices, phone numbers, addresses and so on.
  6834.     
  6835.     ----------------
  6836.     Multiple Columns
  6837.     ----------------
  6838.     
  6839.     You can use the same lookup file to find different items that are related
  6840.     to the same key field.  For example, let's say you have created a lookup
  6841.     file, named EMPLOYEE.TBL, which looks like this:
  6842.     
  6843.     ; EMPLOYEE#   NAME           PHONE
  6844.       00001       John Smith     555-1212
  6845.       00002       Mary Jones     555-2121
  6846.       00003       Fred Johnson   555-1122
  6847.     
  6848.     You could look up an employee's name and phone number as follows:
  6849.     
  6850.     LOOKFILE "EMPLOYEE.TBL"
  6851.     LOOKCOLS "3" "7" "15" "37"
  6852.     LOOKSPEC "N" "Y" "N"
  6853.     LOOKUP   empdata = "00002"
  6854.     SET      name  = empdata[ 1 12]
  6855.     SET      phone = empdata[16 23]
  6856.     TRIM     name  "B" " "
  6857.     TRIM     phone "B" " "
  6858.     
  6859.     You could, of course, specify a different LOOKCOLS prior to each LOOKUP,
  6860.     but that would mean reading the disk twice.  It most cases, it is faster
  6861.     to obtain the data all at once, then extract it.
  6862.     
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868.  
  6869.  
  6870.  
  6871.  
  6872.  
  6873.  
  6874.                                                                             116
  6875.     -------------------
  6876.     LOOKUP Versus REMAP
  6877.     -------------------
  6878.     
  6879.     If you have only a few thousand bytes of lookup data, you might be able to
  6880.     use the REMAP command instead of LOOKUP.  However, you can not simply
  6881.     replace LOOKFILE and LOOKUP with MAPFILE and REMAP.  REMAP does not return
  6882.     a null value if it can not find the item being sought, so you will have to
  6883.     change your POM file to compare the original string with the revised
  6884.     string, in order to see if it has changed (i.e. it was found).  Even with
  6885.     this test, REMAP might "fool you" if it finds a partial match.
  6886.     
  6887.     If you are processing a lot of input data, using REMAP may speed up
  6888.     processing, since REMAP works in RAM memory, while LOOKUP reads the disk.
  6889.     However, if your disk uses "caching", the performance improvement may be
  6890.     negligible.
  6891.     
  6892.                                 --------------------
  6893.                                 The LOOKFILE Command
  6894.                                 --------------------
  6895.     
  6896.     FORMAT:        LOOKFILE value1
  6897.     
  6898.     PURPOSE:       The LOOKFILE command specifies the name of the look-up file
  6899.                    for the next LOOKUP command.
  6900.     
  6901.     SEE ALSO:      "How Parse-O-Matic Searches for a File"
  6902.     
  6903.     LOOKFILE lets you use several look-up files in one POM file. For example:
  6904.     
  6905.     SET      name = $FLINE[1 20]
  6906.     ;   Look up the name
  6907.     LOOKFILE "NAMES.TBL"
  6908.     LOOKCOLS "1" "25" "30" "50"
  6909.     LOOKUP   fullname = name
  6910.     ;   Look up phone number
  6911.     LOOKFILE "PHONE.TBL"
  6912.     LOOKCOLS "1" "25" "30" "40"
  6913.     LOOKUP   phone = name
  6914.     ;   Output result
  6915.     OUTEND   |{name} {fullname} {newname}
  6916.     
  6917.     If you only have one look-up file, you may omit the LOOKFILE command and
  6918.     specify the file name on the command line, using the /L parameter.  For
  6919.     example, you could write a POM file like this:
  6920.     
  6921.     SET      name = $FLINE[1 20]
  6922.     ;   Look up the name
  6923.     LOOKCOLS "1" "25" "30" "50"
  6924.     LOOKUP   fullname = name
  6925.     ;   Output result
  6926.     OUTEND   |{name} {fullname}
  6927.     
  6928.  
  6929.                                                                             117
  6930.     Your POM command could then look like this:
  6931.     
  6932.     POM MYPOM.POM INPUT.TXT OUTPUT.TXT /LC:\MYFILES\NAMES.TBL
  6933.     
  6934.     This technique allows you to use several different look-up files with the
  6935.     same POM file, simply by changing the command line.  (The method by which
  6936.     Parse-O-Matic finds the file is discussed in the section "How Parse-O-Matic
  6937.     Searches for a File".)
  6938.     
  6939.     The longest line allowed in a look-up file is 255 characters long.
  6940.     
  6941.     If you specify a null look-up file name (e.g. LOOKFILE ""), Parse-O-Matic
  6942.     closes the current look-up file (if one is open).  This is necessary if you
  6943.     wish to delete the file, using the ERASE command.
  6944.     
  6945.                                 --------------------
  6946.                                 The LOOKCOLS Command
  6947.                                 --------------------
  6948.     
  6949.     FORMAT:        LOOKCOLS value1 value2 value3 value4
  6950.     
  6951.     PURPOSE:       The LOOKCOLS command specifies the starting and ending
  6952.                    columns for the key and data fields in a look-up file (see
  6953.                    the explanation of the LOOKUP command for an overview of
  6954.                    look-up files).
  6955.     
  6956.     PARAMETERS:    value1 specifies the starting column for the key  field
  6957.                    value2 specified the  ending  column for the key  field
  6958.                    value3 specifies the starting column for the data field
  6959.                    value4 specified the  ending  column for the data field
  6960.     
  6961.     NUMERICS:      Tabs, spaces and commas are stripped from value1, 2, 3 and 4
  6962.     
  6963.     You can specify a null value to indicate "same as last time".  For example:
  6964.     
  6965.     SET name = $FLINE[1 20]
  6966.     LOOKFILE "NAMES.TBL"
  6967.     LOOKCOLS "1" "25" "30" "50"
  6968.     LOOKUP   fullname = name
  6969.     LOOKFILE "PHONE.TBL"
  6970.     LOOKCOLS "" "" "" "40"
  6971.     LOOKUP   phonenum = name
  6972.     OUTEND   |{name} {fullname} {phonenum}
  6973.     
  6974.     The second LOOKCOLS command uses the same numbers for the first three
  6975.     values that the first LOOKCOLS command used.
  6976.     
  6977.  
  6978.  
  6979.  
  6980.  
  6981.  
  6982.  
  6983.  
  6984.                                                                             118
  6985.     If you do not specify a LOOKCOLS command, the default values are:
  6986.     
  6987.     Key Field:   Starting column  =   1
  6988.                  Ending column    =  10
  6989.     Data Field:  Starting column  =  12
  6990.                  Ending column    = 255
  6991.     
  6992.     This is equivalent to LOOKCOLS "1" "10" "12" "255".
  6993.     
  6994.                                 --------------------
  6995.                                 The LOOKSPEC Command
  6996.                                 --------------------
  6997.     
  6998.     FORMAT:        LOOKSPEC value1 value2 value3
  6999.     
  7000.     PURPOSE:       The LOOKSPEC command configures the way the next LOOKUP
  7001.                    command will work.
  7002.     
  7003.     PARAMETERS:    value1 = Trim           ("Y" or "N" -- default "Y")
  7004.                    value2 = Sorted         ("Y" or "N" -- default "N")
  7005.                    value3 = Case-sensitive ("Y" or "N" -- default "N")
  7006.     
  7007.     The Trim setting specifies whether or not the data field should have spaces
  7008.     stripped off both ends.
  7009.     
  7010.     The Sorted setting specifies whether or not the look-up file is sorted by
  7011.     the key field.  A sorted file is much faster than an unsorted file.  This
  7012.     is especially noticeable if you have a large look-up file and a lot of
  7013.     input to process.
  7014.     
  7015.     The Case-sensitive setting specifies whether or not LOOKUP should distin-
  7016.     guish between upper and lower case when searching.  The default setting is
  7017.     "N" (No), so that LOOKUP would find "John Smith", even if it appeared in
  7018.     the look-up file as "JOHN SMITH".  It is usually safest to set Case-
  7019.     sensitivity to "N", but if you set it to "Y", searching is slightly faster.
  7020.     
  7021.     You can specify a null value to indicate "same as last time".  For example:
  7022.     
  7023.     SET name = $FLINE[1 20]
  7024.     LOOKFILE "DATA.TBL"
  7025.     LOOKCOLS "1" "25" "30" "50"
  7026.     LOOKSPEC "Y" "Y" "Y"
  7027.     LOOKUP   fullname = name
  7028.     LOOKCOLS "" "" "60" "70"
  7029.     LOOKSPEC "N" "" ""
  7030.     LOOKUP   phonenum = name
  7031.     OUTEND   |{name} {fullname} {phonenum}
  7032.     
  7033.     The second LOOKSPEC command uses the same settings for Sorted and Case-
  7034.     sensitivity as the first one, but specifies a different Trim setting.
  7035.     
  7036.     
  7037.     
  7038.  
  7039.                                                                             119
  7040.     ============================================================================
  7041.                                   DATA CONVERTERS
  7042.     ============================================================================
  7043.     
  7044.                                 --------------------
  7045.                                 The MAKEDATA Command
  7046.                                 --------------------
  7047.     
  7048.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  7049.     
  7050.     FORMAT:        MAKEDATA var1 value1 value2
  7051.     
  7052.     PURPOSE:       MAKEDATA converts text data into a binary format.
  7053.     
  7054.     PARAMETERS:    var1     is the variable being set
  7055.                    value1   is the text data you want to convert
  7056.                    value2   is the predefined data type you want to create
  7057.     
  7058.     NUMERICS:      Tabs, spaces and commas are stripped from value1, if it is
  7059.                    numeric (as indicated by value2)
  7060.     
  7061.     SEE ALSO:      "Predefined Data Types" and "The CalcBits Command"
  7062.     
  7063.     When you are writing to a binary file (using the OUT command), you often
  7064.     need to convert text information to a binary representation.  MAKEDATA
  7065.     recognizes many standard data formats (see "Predefined Data Types").
  7066.     
  7067.     --------------------
  7068.     Creating Binary Data
  7069.     --------------------
  7070.     
  7071.     Let us say you have a four-line text file that looks like this:
  7072.     
  7073.      1234
  7074.      -456
  7075.        23
  7076.     90211
  7077.     
  7078.     Here is a POM file that reads the numbers from the file, then outputs them
  7079.     in binary format, as 16-bit signed integers:
  7080.     
  7081.     MAKEDATA z $FLINE "INTEGER"    <-- Convert the number to an integer
  7082.     OUT      |{z}                  <-- Send the integer to the output file
  7083.     
  7084.     We use OUT instead of OUTEND, since OUTEND would put an end-of-line
  7085.     (Carriage Return, Line Feed) after the data.
  7086.     
  7087.     If the POM file shown in the example was run with the input data shown,
  7088.     it would create an output file containing four integers.  In other words,
  7089.     the file would be eight bytes long (four integers of two bytes each).
  7090.     
  7091.  
  7092.  
  7093.  
  7094.                                                                             120
  7095.     ----------------
  7096.     Converting Dates
  7097.     ----------------
  7098.     
  7099.     In some files, a date serial number (see "The ZeroDate Command") might be
  7100.     represented by a numeric format such as INTEGER or LONGINT.  To write a
  7101.     date serial number to the output file, you must first convert the date with
  7102.     MAKEDATA, then use MAKEDATA again to convert the resulting number to the
  7103.     appropriate data type.
  7104.     
  7105.     The value1 part of the MAKEDATA must be in a precise format:
  7106.     
  7107.     "YYYY [M]M [D]D"               <-- Square brackets indicate optional digits
  7108.     
  7109.     That is to say:
  7110.     
  7111.     1) A four-digit year
  7112.     2) A space
  7113.     3) A one or two digit month (January = 1 or 01, December = 12)
  7114.     4) A space
  7115.     5) A one or two digit day of the month (e.g. 1 or 01 or 31)
  7116.     
  7117.     You can assemble the date string from various other data, using the
  7118.     DATE command.  Let us say you have a one-line text file that contains
  7119.     the date in Month-Day-Year format:
  7120.     
  7121.     01-01-2001
  7122.     
  7123.     You can read this file and output a date serial number as a long integer
  7124.     (LONGINT) with the following POM file:
  7125.     
  7126.     ZERODATE "2000" "1" "1"                <-- Set "day zero"
  7127.     SET      year  = $FLINE[7 10]          <-- Get the year
  7128.     SET      month = $FLINE[1  2]          <-- Get the month
  7129.     SET      day   = $FLINE[4  5]          <-- Get the day of the month
  7130.     DATE     x year month day "Y ?n ?d"    <-- Set x to "2001 01 01"
  7131.     MAKEDATA y x "DATE"                    <-- Set y to "366"
  7132.     MAKEDATA z y "LONGINT"                 <-- Set z to a long integer
  7133.     OUT      |{z}                          <-- Place it in the output file
  7134.     
  7135.     A typical problem with date data is that the year does not include
  7136.     the first two digits (e.g. you have "97" instead of "1997").  In
  7137.     such cases, your POM file has to make a decision as to which century
  7138.     the date belongs to.  Here is one way to handle this situation:
  7139.     
  7140.     BEGIN year #>= "50"
  7141.       CALC year = year + "1900"
  7142.     ELSE
  7143.       CALC year = year + "2000"
  7144.     END
  7145.     
  7146.  
  7147.  
  7148.  
  7149.                                                                             121
  7150.     This works around the problem as follows:
  7151.     
  7152.             Any year between     is placed in         Examples
  7153.             ----------------     ----------------     --------------
  7154.             "50" and "99"        the 20th century     "1950"  "1999"
  7155.             "00" and "49"        the 21st century     "2000"  "2049"
  7156.     
  7157.     You have to be careful when choosing the "cut-off date" (1950, in the
  7158.     example above).  You should make your decision only after studying your
  7159.     input data carefully.
  7160.     
  7161.     ------------------------
  7162.     Practical Considerations
  7163.     ------------------------
  7164.     
  7165.     The examples shown here assume that your input file contains only one kind
  7166.     of data.  In most cases, you will use the CHOP command to obtain complete
  7167.     data records of fixed length, then use SET to extract portions thereof.
  7168.     If you are reading a file with variable-length records, you can use CHOP 0
  7169.     (manual reading) and the GET command.
  7170.     
  7171.                                 --------------------
  7172.                                 The MAKETEXT Command
  7173.                                 --------------------
  7174.     
  7175.                    ** ADVANCED COMMAND FOR EXPERIENCED USERS **
  7176.     
  7177.     FORMAT:        MAKETEXT var1 value1 value2
  7178.     
  7179.     PURPOSE:       MAKETEXT converts binary data into text format.
  7180.     
  7181.     PARAMETERS:    var1     is the variable being set
  7182.                    value1   is the data you want to convert
  7183.                    value2   is the predefined data type of value1
  7184.     
  7185.     NOTES:         value1 is normally in binary (i.e. it looks like "garbage
  7186.                    characters" if you output it to a text file).  However, if
  7187.                    value2 specifies the DATE data type, value1 must be in text
  7188.                    form (e.g. "1234").  The reason for this difference is
  7189.                    described in the "Converting Dates" section below.
  7190.     
  7191.     SEE ALSO:      "Predefined Data Types"
  7192.     
  7193.     When reading a binary file (using the CHOP command), you often need to
  7194.     convert binary information to a text representation. MAKETEXT recognizes
  7195.     many standard data formats (see "Predefined Data Types").
  7196.     
  7197.  
  7198.  
  7199.  
  7200.  
  7201.  
  7202.  
  7203.  
  7204.                                                                             122
  7205.     ----------------------
  7206.     Converting Binary Data
  7207.     ----------------------
  7208.     
  7209.     Let us say you have a binary file that contains several WORD values
  7210.     (unsigned integers, each of which is 2 bytes long).  You can read and
  7211.     decode them with the following POM file:
  7212.     
  7213.     CHOP 1-2                            <-- Read the file two bytes at a time
  7214.     MAKETEXT x $FLINE "WORD"            <-- Convert the WORD to text format
  7215.     OUTEND   |{x}                       <-- Output the data to a text file
  7216.     
  7217.     ----------------
  7218.     Converting Dates
  7219.     ----------------
  7220.     
  7221.     MAKETEXT can convert a date serial number (see "The ZeroDate Command") to
  7222.     a formatted date.  Since there is no standard data format for date serial
  7223.     numbers, you must use MAKETEXT to convert the number into text form, and
  7224.     then use MAKETEXT again to format the date.
  7225.     
  7226.     Let us say you have a binary file that contains dates, represented as
  7227.     LONGINTs (4-byte signed integers).  You could convert them to dates with
  7228.     the following POM file:
  7229.     
  7230.     CHOP 1-4                     <-- Read 4 bytes at a time
  7231.     ZERODATE "1936" "1" "1"      <-- Set the "zero date"
  7232.     MAKETEXT x $FLINE "LONGINT"  <-- Convert the binary data to a text number
  7233.     MAKETEXT y x "DATE Y-M-?d"   <-- Convert to text date (e.g. "1998-JUL-01")
  7234.     OUTEND   |{y}                <-- Output the date to a text file
  7235.     
  7236.     ------------------------
  7237.     Practical Considerations
  7238.     ------------------------
  7239.     
  7240.     The examples shown here assume that your input file contains only one kind
  7241.     of data.  In most cases, you will use the CHOP command to obtain complete
  7242.     data records of fixed length, then use SET to extract portions thereof.
  7243.     If you are reading a file with variable-length records, you can use CHOP 0
  7244.     (manual reading) and the GET command.
  7245.     
  7246.     
  7247.     
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.  
  7256.  
  7257.  
  7258.  
  7259.                                                                             123
  7260.     ============================================================================
  7261.                                MISCELLANEOUS COMMANDS
  7262.     ============================================================================
  7263.     
  7264.                                  -----------------
  7265.                                  The ERASE Command
  7266.                                  -----------------
  7267.     
  7268.     FORMAT:        ERASE value1
  7269.     
  7270.     PURPOSE:       Deletes a file (if it exists).
  7271.     
  7272.     PARAMETERS:    value1 is the name of the file to be deleted
  7273.     
  7274.     SEE ALSO:      "Long File Names in Win95"
  7275.     
  7276.     Here is an example of the ERASE command:
  7277.     
  7278.     ERASE "C:\XYZ.TXT"
  7279.     
  7280.     This will delete the file C:\XYZ.TXT if it exists.  If it does not exist,
  7281.     nothing is done.
  7282.     
  7283.     You can not delete the current input file, output file, trace file or
  7284.     lookup file.  If you attempt to do so, Parse-O-Matic will terminate with
  7285.     an error.
  7286.     
  7287.     You can not delete a device (e.g. ERASE "LPT1:").  The ERASE command
  7288.     simply ignores such requests.
  7289.     
  7290.     If value1 is preceded by a "+" character, the plus sign is ignored.
  7291.     See "How Parse-O-Matic Opens an Output File" for an explanation of the
  7292.     significance of the plus sign.
  7293.     
  7294.  
  7295.  
  7296.  
  7297.  
  7298.  
  7299.  
  7300.  
  7301.  
  7302.  
  7303.  
  7304.  
  7305.  
  7306.  
  7307.  
  7308.  
  7309.  
  7310.  
  7311.  
  7312.  
  7313.  
  7314.                                                                             124
  7315.                                --------------------
  7316.                                The FILESIZE Command
  7317.                                --------------------
  7318.     
  7319.     FORMAT:        FILESIZE var1 value1
  7320.     
  7321.     PURPOSE:       Determines the size of a file, in bytes
  7322.     
  7323.     PARAMETERS:    var1   is the variable being set with the file size
  7324.                    value1 is the name of the file
  7325.     
  7326.     SEE ALSO:      "Long File Names in Win95"
  7327.     
  7328.     The FILESIZE command can be used to obtain the size of a file, or to see
  7329.     if a file exists.
  7330.     
  7331.     If the file does not exist, FILESIZE sets var1 to a null ("") string.
  7332.     
  7333.     If the file exists, FILESIZE sets var1 to the number of bytes in the
  7334.     file (from 0 to 2,147,483,647 bytes).
  7335.     
  7336.     For those rare files that are larger than 2,147,483,647 bytes, FILESIZE will
  7337.     produce an unpredictable result and may even cause Parse-O-Matic to fail.
  7338.     Nevertheless, it is possible to process such large files -- all of the other
  7339.     commands will work normally.
  7340.     
  7341.                                  ------------------
  7342.                                  The GETENV Command
  7343.                                  ------------------
  7344.     
  7345.     FORMAT:        GETENV var1 value1
  7346.     
  7347.     PURPOSE:       GETENV obtains a system environment variable
  7348.     
  7349.     PARAMETERS:    var1   is the variable being set
  7350.                    value1 is the name of the system environment variable
  7351.     
  7352.     NOTES:         System environment variables are sometimes referred to as
  7353.                    "DOS Environment Variables" or "SET Variables".
  7354.     
  7355.     SEE ALSO:      Explanations of the SET & PATH commands in your DOS manual,
  7356.                    or "The Environment Area" in your Windows or OS/2 manual.
  7357.     
  7358.     ALTERNATIVES:  See "Command-line Parameters" in the "Command-Line
  7359.                    Techniques" section of this manual.
  7360.     
  7361.     GETENV enables you to access certain important settings that concern your
  7362.     computer's operating system.  To see what settings are available, enter the
  7363.     following command at the DOS prompt:
  7364.     
  7365.     SET
  7366.     
  7367.  
  7368.  
  7369.                                                                             125
  7370.     This will display the contents of your computer's "environment area".  Two
  7371.     of the most important values in the environment area are COMSPEC and PATH.
  7372.     These are briefly described later, but refer to your operating system
  7373.     manual for full details.
  7374.     
  7375.     GETENV removes all spaces, tabs and equals-signs ("=") from value1,
  7376.     converts it to uppercase, then looks it up in the system environment area.
  7377.     
  7378.     - If it finds it, var1 is set to the corresponding value.
  7379.     - If it does not find it, var1 is set to an empty (null) string.
  7380.     
  7381.     ----------------------------------
  7382.     Disappearing Environment Variables
  7383.     ----------------------------------
  7384.     
  7385.     Sometimes an environment variable disappears for no apparent reason.  There
  7386.     are two likely reasons for this:
  7387.     
  7388.     1)  You ran out of environment space.
  7389.     
  7390.         There is only a limited amount of room in the system environment area
  7391.         (which is located in RAM memory).  If you think this is the problem,
  7392.         type your DOS SET command to save a variable into the system
  7393.         environment, then type SET by itself to review the contents of the
  7394.         environment.  If your variable does not appear, consult your operating
  7395.         system manual to find out how to expand your environment space.
  7396.     
  7397.     2)  It was set by a COPY of the operating system.
  7398.     
  7399.         If you are in Windows and you run DOS, then use the DOS SET command, it
  7400.         will only affect the environment area associated with the copy of DOS
  7401.         that you are running.  When you exit this copy and start up another
  7402.         one, it will not contain the variable.  You can address this problem by
  7403.         setting the variable in your AUTOEXEC.BAT file, or by running a batch
  7404.         file that sets the variable before running Parse-O-Matic.
  7405.     
  7406.     --------
  7407.     Examples
  7408.     --------
  7409.     
  7410.     The following command will determine which directories get searched when
  7411.     you are looking for a program or a file:
  7412.     
  7413.     GETENV path "PATH"
  7414.     
  7415.     To find out the name of your command interpreter (usually COMMAND.COM)
  7416.     and where it is located, try this command:
  7417.     
  7418.     GETENV comspec "COMSPEC"
  7419.     
  7420.     You can use GETENV as a simple "input routine" for Parse-O-Matic
  7421.     applications.  For details, see "Controlling a POM File from the Command
  7422.     Line", in the section entitled "Effective Use of Batch Files".
  7423.  
  7424.                                                                             126
  7425.                                   ---------------
  7426.                                   The LOG Command
  7427.                                   ---------------
  7428.     
  7429.     FORMAT:        LOG value1 [comparator] value2 value3 [value4 [value5]]
  7430.     
  7431.     PURPOSE:       LOG places a message (value3) in the processing log file
  7432.                    (POMLOG.TXT) if the comparison is true.  Both value4 and
  7433.                    value5 are optional; if they are present, they are added
  7434.                    to end of value3.
  7435.     
  7436.     NOTES:         The processing log is described in the section "Logging".
  7437.     
  7438.     ALTERNATIVES:  The SHOWNOTE command
  7439.     
  7440.     Here is an example of the LOG command:
  7441.     
  7442.     SET   emplnumb = $FLINE[ 1  9]
  7443.     SET   sales    = $FLINE[10 20]
  7444.     TRIM  sales "B" " "
  7445.     LOG   sales = "0" "WARNING!  Zero sales for employee number:"
  7446.     LOG   sales = "0" emplnumb
  7447.     
  7448.     This adds two warning lines to the processing log if the sales figures is
  7449.     zero.
  7450.     
  7451.     The logging feature lets you run Parse-O-Matic unattended, then come back
  7452.     later to review (via the processing log) any exceptional conditions.  For
  7453.     some additional comments on logging, see "Unattended Operation".
  7454.     
  7455.     The maximum length of a LOG string (value3, plus value4 and value5 if
  7456.     present) is 245 characters.
  7457.     
  7458.  
  7459.  
  7460.  
  7461.  
  7462.  
  7463.  
  7464.  
  7465.  
  7466.  
  7467.  
  7468.  
  7469.  
  7470.  
  7471.  
  7472.  
  7473.  
  7474.  
  7475.  
  7476.  
  7477.  
  7478.  
  7479.                                                                             127
  7480.                                 -------------------
  7481.                                 The MSGWAIT Command
  7482.                                 -------------------
  7483.     
  7484.     FORMAT:        MSGWAIT value1
  7485.     
  7486.     PURPOSE:       MSGWAIT controls the amount of time that a processing error
  7487.                    message appears on the screen before it times out. (Messages
  7488.                    from the HALT command are treated as error messages.)
  7489.     
  7490.     PARAMETERS:    value1 is the delay time in seconds
  7491.     
  7492.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  7493.     
  7494.     DEFAULTS:      If the MSGWAIT command is not included in the POM file, and
  7495.                    an error occurs, Parse-O-Matic will wait until you press a
  7496.                    key; the message will not time out.
  7497.     
  7498.     NOTES:         If value1 is "0", error messages will not time out.
  7499.                    The maximum value for value1 is 60000 (about 16 hours).
  7500.                    You can set value1 to "1", but one second is usually too
  7501.                    short a delay; a value of "60" (one minute) is better.
  7502.     
  7503.     SEE ALSO:      "The Halt Command", "Unattended Operation", "Quiet Mode"
  7504.     
  7505.     The MSGWAIT command lets you control the behaviour of error messages that
  7506.     appear during the processing of an input file.  This is helpful if you
  7507.     have created POM applications that are run unattended.
  7508.     
  7509.     If Parse-O-Matic was invoked by a batch file or application program, you
  7510.     want may error messages to "time out", allowing Parse-O-Matic to terminate,
  7511.     and processing to continue.
  7512.     
  7513.     ------------------
  7514.     Standard Behaviour
  7515.     ------------------
  7516.     
  7517.     If Parse-O-Matic encounters an error while reading in a POM file (i.e.
  7518.     during the "compile" step), it displays a message on the screen and waits
  7519.     until you press a key.  Parse-O-Matic then terminates.
  7520.     
  7521.     When running the actual POM file (i.e. while processing the input file),
  7522.     Parse-O-Matic will normally behave the same way:  if an error occurs (or
  7523.     if a HALT command is encountered), it will display a message on the screen
  7524.     and wait for you to press a key before it terminates.
  7525.     
  7526.  
  7527.  
  7528.  
  7529.  
  7530.  
  7531.  
  7532.  
  7533.  
  7534.                                                                             128
  7535.     ------------------------
  7536.     Setting a Time-Out Delay
  7537.     ------------------------
  7538.     
  7539.     You can use the MSGWAIT command to tell Parse-O-Matic to continue ("time
  7540.     out") after a certain number of seconds.  For example:
  7541.     
  7542.     MSGWAIT "60"
  7543.     
  7544.     This tells Parse-O-Matic to wait about 60 seconds if an error is
  7545.     encountered while processing the input file.  Parse-O-Matic will then
  7546.     terminate.  (The actual delay depends on the type of computer you are
  7547.     using; a delay of "60" will typically last between 55 and 65 seconds).
  7548.     
  7549.     ----------
  7550.     Color Cues
  7551.     ----------
  7552.     
  7553.     If you have a color monitor, you can tell if a message will "time out"
  7554.     by the color of the "Press a key to continue" prompt:
  7555.     
  7556.     - If it is magenta (sometimes called "purple") it will NOT time out
  7557.     - If it is blue, if WILL time out
  7558.     
  7559.     ------------
  7560.     Key Stacking
  7561.     ------------
  7562.     
  7563.     To ensure that an error message is not inadvertently bypassed, "stacked"
  7564.     keystrokes are ignored by Parse-O-Matic.  That is to say, if you press
  7565.     several keys before an error message is displayed, Parse-O-Matic gets rid
  7566.     of them before displaying the message.
  7567.     
  7568.     ----------
  7569.     Exceptions
  7570.     ----------
  7571.     
  7572.     If Parse-O-Matic is processing an empty input file, it will display the
  7573.     warning "Input file is empty", then continue processing the POM file when
  7574.     you press a key, or after a delay of about 60 seconds.
  7575.     
  7576.     The MSGWAIT command does not affect messages that report errors detected
  7577.     during the compilation (initial read-in) of the POM file.
  7578.     
  7579.     The MSGWAIT command does not affect the "Retry or Cancel" message that
  7580.     appears if you are dealing with a device (see "Sending Output to a
  7581.     Device").
  7582.     
  7583.  
  7584.  
  7585.  
  7586.  
  7587.  
  7588.  
  7589.                                                                             129
  7590.     -----------------
  7591.     A Word of Caution
  7592.     -----------------
  7593.     
  7594.     A POM file should be thoroughly tested before setting the MSGWAIT time to a
  7595.     value other than "0".  Most error messages are serious enough to justify
  7596.     waiting until the user acknowledges them.
  7597.     
  7598.     If you call Parse-O-Matic from a batch file or application program, you can
  7599.     check the success of the parsing job by checking the return code.  (See
  7600.     "Effective Use of Batch Files" and "Running Parse-O-Matic from Another
  7601.     Program").
  7602.     
  7603.     If there was a processing error and you did not check the parsing job
  7604.     (either by testing the program return code, or by consulting the
  7605.     processing log), the resulting oversight could be serious.
  7606.     
  7607.                                  -----------------
  7608.                                  The PAUSE Command
  7609.                                  -----------------
  7610.     
  7611.     FORMAT:        PAUSE value1
  7612.     
  7613.     PURPOSE:       Delays the specified number of milliseconds
  7614.     
  7615.     PARAMETERS:    value1 is the delay time (between 1 and 65500)
  7616.     
  7617.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  7618.     
  7619.     NOTES:         1     millisecond  = One thousandth of a second
  7620.                    100   milliseconds = One tenth of a second
  7621.                    1000  milliseconds = One second
  7622.                    60000 milliseconds = One minute
  7623.     
  7624.     Here are some typical applications of the PAUSE command:
  7625.     
  7626.     - Slow down Parse-O-Matic so you can watch the processing screen
  7627.     - Give a slow laser printer extra time to eject a page after an OUTPAGE
  7628.     - Give you time to remove a page from a dot-matrix printer after an OUTPAGE
  7629.     - Give a communications device time to complete its current operation
  7630.     
  7631.     Here is an example of the latter application:
  7632.     
  7633.     OFILE  "COM1:"             <-- Direct output to the modem on COM1
  7634.     OUTEND |ATZ                <-- Send a modem initialization command
  7635.     PAUSE  "1000"              <-- Wait one second for the command to complete
  7636.     OUTEND |ATDT555-1234       <-- Send a dialing command to the modem
  7637.     
  7638.     If your PAUSE command is 200 milliseconds or longer, Parse-O-Matic displays
  7639.     a "PAUSED" message in the lower right corner of the processing screen.
  7640.     While this appears, you can press any key to end the pause.  (We recommend
  7641.     that you use the spacebar -- and avoid the Esc key.  Parse-O-Matic
  7642.     processing will be terminated if the PAUSE happens to end at the precise
  7643.  
  7644.                                                                             130
  7645.     moment your finger is coming down on the Esc key!)
  7646.     
  7647.                                  ------------------
  7648.                                  The RANDOM Command
  7649.                                  ------------------
  7650.     
  7651.     FORMAT:        RANDOM var1 value1 value2
  7652.     
  7653.     PURPOSE:       Generates a random integer number
  7654.     
  7655.     PARAMETERS:    var1   is the variable being set
  7656.                    value1 is the minimum number allowed (between 0 and 65534)
  7657.                    value2 is the maximum number allowed (between 0 and 65534)
  7658.     
  7659.     NUMERICS:      Tabs, spaces and commas are stripped from value1
  7660.     
  7661.     The RANDOM command generates a random number in the range specified by
  7662.     value1 and value2.  For example, to simulate the rolling of a six-sided
  7663.     die:
  7664.     
  7665.     RANDOM   roll "1" "6"
  7666.     
  7667.     The first time you call this, it might set the roll variable to "3".  The
  7668.     next time, it might set it to "1".  The roll variable will never be lower
  7669.     than "1" or higher than "6".
  7670.     
  7671.     The minimum value must always be less than or equal to the maximum value.
  7672.     Thus, the following statement will cause an error:
  7673.     
  7674.     RANDOM   x "100" "1"        <-- This is incorrect
  7675.     
  7676.     If value1 and value2 are the same, RANDOM will always generate the same
  7677.     number.
  7678.     
  7679.     SET      n = "50"
  7680.     RANDOM   z n n
  7681.     
  7682.     This will always set the z variable to 50.
  7683.     
  7684.  
  7685.  
  7686.  
  7687.  
  7688.  
  7689.  
  7690.  
  7691.  
  7692.  
  7693.  
  7694.  
  7695.  
  7696.  
  7697.  
  7698.  
  7699.                                                                             131
  7700.                                 --------------------
  7701.                                 The SHOWNOTE Command
  7702.                                 --------------------
  7703.     
  7704.     FORMAT:        SHOWNOTE value1 [value2] [value3] [value4] [value5]
  7705.     
  7706.     PURPOSE:       Displays a message on the processing screen
  7707.     
  7708.     PARAMETERS:    value1 to value5 are values that will be displayed
  7709.     
  7710.     ALTERNATIVES:  The LOG command
  7711.     
  7712.     When you are doing especially intense parsing, it is nice to see some kind
  7713.     of indication of what is happening.  The SHOWNOTE command displays a message
  7714.     up to 40 characters long in the lower left corner of the processing screen.
  7715.     For example:
  7716.     
  7717.     SHOWNOTE "Reading employee data"
  7718.     
  7719.     This will display the message "Reading employee data" until the parsing job
  7720.     ends, or until another SHOWNOTE command is encountered.
  7721.     
  7722.     You can remove a note from the processing screen by providing a null value:
  7723.     
  7724.     SHOWNOTE ""
  7725.     
  7726.     This clears a note that is already on the processing screen.
  7727.     
  7728.     You can display up to 5 values in a SHOWNOTE message.  Each value will be
  7729.     separated from the others by a space.  For example:
  7730.     
  7731.     SHOWNOTE "Employee:" empnum " -- Last name:" lastname
  7732.     
  7733.     This would display a note like this:
  7734.     
  7735.     Employee: 314159 -- Last name: Smith
  7736.     
  7737.     Bear in mind that you have only 40 characters for the note.  If the lastname
  7738.     variable in the preceding example was "Von Neumann", the display would be
  7739.     truncated to forty characters, and display the note as follows:
  7740.     
  7741.     Employee: 314159 -- Last name: Von Neuma
  7742.     
  7743.  
  7744.  
  7745.  
  7746.  
  7747.  
  7748.  
  7749.  
  7750.  
  7751.  
  7752.  
  7753.  
  7754.                                                                             132
  7755.     -----------
  7756.     Other Notes
  7757.     -----------
  7758.     
  7759.     There are three kinds of notes that are displayed in the lower right corner
  7760.     of the processing screen:
  7761.     
  7762.       TYPE OF NOTE     COLOR       TEXT                   REASON
  7763.       -------------   ----------   --------------------   --------------------
  7764.       SHOWNOTE        Light Grey   Whatever you specify   The SHOWNOTE command
  7765.       PAUSE           Light Red    PAUSED                 The PAUSE command
  7766.       Error message   Red          TRYING TO PRINT        Printer is offline
  7767.     
  7768.     In most cases, these messages will not interfere with each other.
  7769.     
  7770.     ------------
  7771.     Slowing Down
  7772.     ------------
  7773.     
  7774.     If you are running Parse-O-Matic on a fast machine, your SHOWNOTE messages
  7775.     blaze by so fast that there are not particuarly helpful. Here is a POM file
  7776.     that demonstrates one solution:
  7777.     
  7778.     SET      line_counter = line_counter+
  7779.     SET      note_control = note_control+
  7780.     BEGIN    note_control = "100"
  7781.       SET      note_control = "0"
  7782.       SHOWNOTE "Processing line #" line_counter
  7783.     END
  7784.     OUTEND   |{$FLINE}
  7785.     
  7786.     This will perform the SHOWNOTE command on every hundredth input line.
  7787.     
  7788.  
  7789.  
  7790.  
  7791.  
  7792.  
  7793.  
  7794.  
  7795.  
  7796.  
  7797.  
  7798.  
  7799.  
  7800.  
  7801.  
  7802.  
  7803.  
  7804.  
  7805.  
  7806.  
  7807.  
  7808.  
  7809.                                                                             133
  7810.                                  -----------------
  7811.                                  The SOUND Command
  7812.                                  -----------------
  7813.     
  7814.     FORMAT:        SOUND value
  7815.     
  7816.     PURPOSE:       The SOUND command performs two functions:
  7817.                    1)  It makes a noise, or ...
  7818.                    2)  It sets the noise made when an error occurs
  7819.     
  7820.     The SOUND command has a repetoire of nine distinctive noises:
  7821.     
  7822.     BEEP BIP BUZZ EDGE ERROR HUH PIP TRILL WHOOP
  7823.     
  7824.     These sounds are useful for alerting you to unusual situations.  Let's say
  7825.     you wanted to be warned if one of the fields in a file comes up blank.  You
  7826.     could write the code this way:
  7827.     
  7828.     BEGIN lastname = ""
  7829.       SOUND "WHOOP"
  7830.       SET   lastname = "?"
  7831.     END
  7832.     
  7833.     Case is not important; the following commands are all equivalent:
  7834.     
  7835.     SOUND "WHOOP"
  7836.     SOUND "Whoop"
  7837.     SOUND "whoop"
  7838.     
  7839.     ------------------
  7840.     The LISTEN Utility
  7841.     ------------------
  7842.     
  7843.     You can listen to any given sound by using the LISTEN command at the DOS
  7844.     prompt.  To hear what TRILL sounds like, enter this command:
  7845.     
  7846.     LISTEN trill
  7847.     
  7848.     By default, Parse-O-Matic error messages will alert you by playing the
  7849.     ERROR sound.  To hear this sound, enter the following command at the DOS
  7850.     prompt:
  7851.     
  7852.     LISTEN error
  7853.     
  7854.  
  7855.  
  7856.  
  7857.  
  7858.  
  7859.  
  7860.  
  7861.  
  7862.  
  7863.  
  7864.                                                                             134
  7865.     --------------------------------
  7866.     Changing the Error Message Sound
  7867.     --------------------------------
  7868.     
  7869.     If you find the error message sound noise annoying, you can replace it with
  7870.     one of the other sounds by using the special ERRMSG specification of the
  7871.     SOUND command.  For example, to replace the ERROR sound with the BUZZ
  7872.     sound, place this line at the top of your POM file:
  7873.     
  7874.     SOUND "ERRMSG BUZZ"
  7875.     
  7876.     If you don't want any sound made when an error occurs, use this command:
  7877.     
  7878.     SOUND "ERRMSG QUIET"
  7879.     
  7880.     The ERRMSG specification will only affect errors generated during the
  7881.     actual running of the POM file.  If an error is encountered while
  7882.     Parse-O-Matic is compiling the POM file, it will use the ERROR sound
  7883.     when it reports the problem.
  7884.     
  7885.                                  -----------------
  7886.                                  The TRACE Command
  7887.                                  -----------------
  7888.     
  7889.     FORMAT:        TRACE var1
  7890.     
  7891.     PURPOSE:       The TRACE command is an alternative to standard tracing (see
  7892.                    "Tracing", in the "Programming Techniques" section).
  7893.     
  7894.     PARAMETERS:    var1 is the variable being traced.
  7895.     
  7896.     When you include a TRACE command in your POM file, Parse-O-Matic will
  7897.     create a text file, named POM.TRC, and use it to keep a detailed record of
  7898.     POM's processing.  Here is an example of the TRACE command:
  7899.     
  7900.     TRACE PRICE
  7901.     
  7902.     This traces the variable named "PRICE".  After processing, the file POM.TRC
  7903.     will show everything that happened, and give the value of PRICE at the
  7904.     TRACE line.
  7905.     
  7906.     NOTE:  Since trace files are so detailed, they can be very large.  If you
  7907.     are trying to debug a POM file using TRACE, it is a good idea to use a
  7908.     small input file.
  7909.     
  7910.     
  7911.     
  7912.  
  7913.  
  7914.  
  7915.  
  7916.  
  7917.  
  7918.  
  7919.                                                                             135
  7920.     ============================================================================
  7921.                                        TERMS
  7922.     ============================================================================
  7923.     
  7924.                                        ------
  7925.                                        Values
  7926.                                        ------
  7927.     
  7928.     A value can be specified in the following ways:
  7929.     
  7930.     FORMAT OR SAMPLE   DESCRIPTION
  7931.     ------------------ -----------
  7932.     "text"             A literal text string
  7933.     #number            An ASCII character, in decimal (e.g. #32 = Space)
  7934.     #number#number...  Several ASCII characters (e.g. #32#32 = 2 Spaces)
  7935.     $xx                A byte, in hexadecimal (e.g. $2F = decimal 47)
  7936.     $xx$xx...          Several hex bytes ($ff$ff = binary 1111111111111111)
  7937.     VARNAME            The name of a variable
  7938.     VARNAME[start end] A substring of a variable
  7939.     VARNAME[start]     A single character
  7940.     VARNAME+           Inline incremented variable (explained below)
  7941.     VARNAME-           Inline decremented variable (explained below)
  7942.     (x,@y,z)           Deduced variable name (see "Deduced Variables")
  7943.     x,y                Explictly specified deduced variable
  7944.     
  7945.                                      ---------
  7946.                                      Variables
  7947.                                      ---------
  7948.     
  7949.     A variable is a named spot in your computer's memory that holds some data.
  7950.     
  7951.     Variable names can be up to 12 characters long.  There is no distinction
  7952.     between upper and lower case in the variable name.  A POM file can contain
  7953.     about 2000 variables and literals.
  7954.     
  7955.     In general, variable names should:
  7956.     
  7957.     - Use letters, numbers and the underscore character
  7958.     - Start with a letter
  7959.     
  7960.     It is possible to create variables that do not adhere to these rules, but
  7961.     this may cause you problems later on (particularly in subsequent releases of
  7962.     Parse-O-Matic which may use special characters to denote particular kinds of
  7963.     variables, or operations performed thereon).
  7964.     
  7965.     The # character is used to specify a literal text string of one or more
  7966.     characters.  Follow each # with the decimal value of the ASCII character
  7967.     you want.  Here are some useful values:
  7968.     
  7969.            #10 = Line Feed   #12 = Form Feed   #13 = Carriage Return
  7970.     
  7971.  
  7972.  
  7973.  
  7974.                                                                             136
  7975.                                  -----------------
  7976.                                  Predefined Values
  7977.                                  -----------------
  7978.     
  7979.     Parse-O-Matic predefines several variables.  These are:
  7980.     
  7981.     VARIABLE     DESCRIPTION
  7982.     ------------ ------------------------------------------------------------
  7983.     $FLINE       The line just read from the file (max. length 255 chars) (*)
  7984.     $FLUPC       The line just read from the file, in uppercase           (*)
  7985.     $SPLIT       The CHOP or SPLIT number you are currently processing    (*)
  7986.     $LINECOUNTER The page line to which output will go next               (*)
  7987.     $COMMAND     The current POM command line (see "POM and Wildcards")
  7988.     $BRL         The { character (used in OUT and OUTEND)
  7989.     $BRR         The } character (used in OUT and OUTEND)
  7990.     $TAB         The tab character (Hex $09; ASCII 09)
  7991.     
  7992.     (*) This is discussed in more detail, below.
  7993.     
  7994.     Although these predefined variables start with a dollar sign ($), it does
  7995.     not mean they are in some way "hexadecimal" (as in the case of the hex
  7996.     values mentioned earlier).  In this case, the $ character indicates that the
  7997.     variables are defined by Parse-O-Matic.  In general, you should avoid
  7998.     creating variables that start with anything but a letter.
  7999.     
  8000.     ------
  8001.     $FLINE
  8002.     ------
  8003.     
  8004.     CONTAINS:    The line just read from the input file
  8005.     SEE ALSO:    The READNEXT, GET and GETTEXT commands
  8006.     
  8007.     $FLINE contains the data just read from the input file (exception:  see
  8008.     "DBF Files").  The data can be intelligible (human-readable) text, or it
  8009.     can be binary information -- Parse-O-Matic does not care what $FLINE
  8010.     contains.
  8011.     
  8012.     The maximum length of $FLINE is 255 bytes.  You can use the SETLEN command
  8013.     to determine its actual length.
  8014.     
  8015.     ------
  8016.     $FLUPC
  8017.     ------
  8018.     
  8019.     CONTAINS:    The line just read from the input file, in uppercase
  8020.     SEE ALSO:    The PROPER and CVTCASE commands
  8021.     
  8022.     $FLUPC is the same as the $FLINE variable, but in uppercase.  Any changes to
  8023.     $FLINE will affect $FLUPC, since they are simply different "views" of the
  8024.     same data.
  8025.     
  8026.     $FLUPC is useful for checking for text inside the current input line if case
  8027.     is not important, and for obtaining the uppercase version of the data. For
  8028.  
  8029.                                                                             137
  8030.     example:
  8031.     
  8032.     BEGIN $FLUPC ^ "PART#"            <-- Detect "Part#", "part#" or "PART#"
  8033.       SET  partnum  = $FLUPC[10 15]   <-- Extract the part number, in uppercase
  8034.       SET  partname = $FLINE[16 30]   <-- Extract the part name, as-is
  8035.     END
  8036.     
  8037.     Since $FLUPC is really just a different view of $FLINE, a modification of
  8038.     $FLUPC (for example, using the PEEL command) is transient and usually
  8039.     pointless; the next reference to $FLUPC will simply return the uppercase
  8040.     version of $FLINE.
  8041.     
  8042.     ------
  8043.     $SPLIT
  8044.     ------
  8045.     
  8046.     CONTAINS:    The CHOP or SPLIT number you are currently processing
  8047.     SEE ALSO:    The GET and GETTEXT commands
  8048.     
  8049.     Since $FLINE has a maximum length of 255 characters, you will have to use
  8050.     the SPLIT or CHOP command if your input file is wider than that.
  8051.     
  8052.     NOTE:  Use SPLIT for text files
  8053.            Use CHOP for fixed-record-length files
  8054.     
  8055.     The $SPLIT variable reports which segment of a CHOPped or SPLIT input line
  8056.     you are currently processing.  For example, if you use this command...
  8057.     
  8058.     CHOP 1 255, 256 380
  8059.     
  8060.     then $SPLIT will be set to "1" when Parse-O-Matic processes columns 1 to
  8061.     255, and it will be set to "2" when processing columns 256 to 380.
  8062.     
  8063.     ------------
  8064.     $LINECOUNTER
  8065.     ------------
  8066.     
  8067.     CONTAINS:    The page line to which output will go next
  8068.     SEE ALSO:    "How Parse-O-Matic Opens an Output File"
  8069.     
  8070.     The $LINECOUNTER variable lets you know the number of the next output line.
  8071.     Consider this POM file:
  8072.     
  8073.     OUTEND |LINE# {$LINECOUNTER}
  8074.     OUTEND |LINE# {$LINECOUNTER}
  8075.     OUTEND |LINE# {$LINECOUNTER}
  8076.     DONE
  8077.     
  8078.     This will produce the following output:
  8079.     
  8080.     LINE# 1
  8081.     LINE# 2
  8082.     LINE# 3
  8083.  
  8084.                                                                             138
  8085.     The OUTPAGE command will reset the $LINECOUNTER to "1", since the next
  8086.     output line will be at the top of the page.  OUTHDG commands also affect
  8087.     the $LINECOUNTER variable.
  8088.     
  8089.     The $LINECOUNTER variable is active even if you have not used the PAGELEN
  8090.     command to set the page length.  By default, the page length is "0" (meaning
  8091.     "infinite"), which means that $LINECOUNTER will always be one greater than
  8092.     the total number of output lines.  However, if you specify an explicit page
  8093.     length (e.g. PAGELEN "55"), $LINECOUNTER is reset to "1" after each page
  8094.     eject.
  8095.     
  8096.     Using the SET command on $LINECOUNTER has no effect.  In some special cases,
  8097.     however, you may wish to reset $LINECOUNTER to "1".  You can do this -- even
  8098.     though you are not at the top of the page -- with the PAGELEN "0" command.
  8099.     (You can then follow this with another PAGELEN command if you want to
  8100.     restore the actual page length.)
  8101.     
  8102.     Here is a sample POM file that demonstrates why you might want to reset the
  8103.     $LINECOUNTER variable.  It will format a text file which contains a form
  8104.     feed character (ASCII 12) at the end of each page, while placing page numbers
  8105.     at the bottom of each page as a "running footing":
  8106.     
  8107.     PROLOGUE                        <-- Start of prologue
  8108.       MINLEN "0"                    <-- Allow null lines
  8109.       SET pagenum = "1"             <-- Set first page number
  8110.     END                             <-- End of prologue
  8111.     BEGIN $FLINE ^ #12              <-- Does this line have a form feed?
  8112.       BEGIN $LINECOUNTER #<= "54"   <-+
  8113.         OUTEND |                      | Put blank lines to the end of the page
  8114.         AGAIN                       <-+
  8115.       APPEND x pagenum #12          <-- Set up the footer (including form feed)
  8116.       PAD x "L" " " "80"            <-- Format the footer
  8117.       OUTEND |{x}                   <-- Output the footer
  8118.       SET pagenum = pagenum+        <-- Increment the page number
  8119.       PAGELEN "0"                   <-- Reset $LINECOUNTER to "1"
  8120.     ELSE
  8121.       OUTEND |    {$FLINE}          <-- Output a regular line
  8122.     END
  8123.     
  8124.     Note that as far as Parse-O-Matic is concerned, the "actual" output page
  8125.     length is "0" (i.e. "infinite"), but this POM file will output a text file
  8126.     that contains 55 lines per page.  (A POM file similar to the one shown is
  8127.     used, with several others, to format this manual.)
  8128.     
  8129.  
  8130.  
  8131.  
  8132.  
  8133.  
  8134.  
  8135.  
  8136.  
  8137.  
  8138.  
  8139.                                                                             139
  8140.                     -------------------------------------------
  8141.                     Running Out of Variables, Literals or Lines
  8142.                     -------------------------------------------
  8143.     
  8144.     A POM file can contain 750 lines (not counting comment lines), and about
  8145.     2000 variables and literals.  If you have a very large POM file, this may
  8146.     not be enough, and you will be forced to do the processing with two or more
  8147.     POM files.  You can link these together with a batch file, as follows:
  8148.     
  8149.     @ECHO OFF
  8150.     POM POMFILE1.POM INPUT.TXT TEMP.TXT
  8151.     IF ERRORLEVEL 1 GOTO QUIT
  8152.     POM POMFILE2.POM TEMP.TXT  FINAL.TXT
  8153.     :QUIT
  8154.     
  8155.                                      ----------
  8156.                                      Delimiters
  8157.                                      ----------
  8158.     
  8159.     If you need to specify a quotation mark, use "".  For example:
  8160.     
  8161.     IGNORE $FLINE = "He said ""Hello"" to me."
  8162.     
  8163.     This ignores any line containing:  He said "Hello" to me.
  8164.     
  8165.                                  ------------------
  8166.                                  Illegal Characters
  8167.                                  ------------------
  8168.     
  8169.     No POM command can contain these ASCII characters:
  8170.     
  8171.                          HEX    DECIMAL  NAME
  8172.                        -------  -------  --------------------
  8173.                          $00      #00    NULL
  8174.                          $0A      #10    LF (Linefeed)
  8175.                          $0D      #13    CR (Carriage Return)
  8176.     
  8177.     Of course, LF and CR do appear at the end of each line in the POM file,
  8178.     command, use either the $ or # character to denote hex or decimal literals
  8179.     (e.g. SET linefeed = $0A).
  8180.     
  8181.  
  8182.  
  8183.  
  8184.  
  8185.  
  8186.  
  8187.  
  8188.  
  8189.  
  8190.  
  8191.  
  8192.  
  8193.  
  8194.                                                                             140
  8195.                                  -----------------
  8196.                                  Using Comparators
  8197.                                  -----------------
  8198.     
  8199.     Several POM command decide what to do by comparing two values. For example:
  8200.     
  8201.     IF $FLINE[1 3] = "XYZ" THEN x = "3" ELSE "4"
  8202.     
  8203.     In this example, if the first three characters of $FLINE are "XYZ", the
  8204.     variable x is set to "3", otherwise it is set to "4".  The first equals
  8205.     sign ("=") is a "comparator", because it defines how two values will be
  8206.     compared.  The second equals sign is not a comparator; it is simply
  8207.     padding, which makes the line easier to understand (see the section
  8208.     "Padding for Clarity" for details).
  8209.     
  8210.     Parse-O-Matic supports the following comparators:
  8211.     
  8212.            COMPARATOR   INTERPRETATION   MEANING                COMMENTS
  8213.            ----------   --------------   --------------------   --------
  8214.            =                Literal      Identical
  8215.            <>               Literal      Not identical
  8216.            >                Literal      Higher                 See NOTE
  8217.            >=               Literal      Higher, or identical   See NOTE
  8218.            <                Literal      Lower                  See NOTE
  8219.            <=               Literal      Lower, or identical    See NOTE
  8220.            ^                Literal      Contains
  8221.            ~                Literal      Does not contain
  8222.            LONGER           Literal      Length is longer
  8223.            SHORTER          Literal      Length is shorter
  8224.            SAMELEN          Literal      Length is the same
  8225.            #=              Numerical     Equal
  8226.            #<>             Numerical     Not equal
  8227.            #>              Numerical     Greater
  8228.            #>=             Numerical     Greater, or equal
  8229.            #<              Numerical     Less than
  8230.            #<=             Numerical     Less than, or equal
  8231.     
  8232.     NOTE:  Depends on PC-ASCII sort order.  Refer to the section "Literal
  8233.            Comparisons and Sort Order" for details.
  8234.     
  8235.     Whenever a comparator is required, but is omitted, it is assumed to be
  8236.     "literally identical".  Thus, the following lines are equivalent:
  8237.     
  8238.         IF x y z "3" "4"                   (This is very terse, but it works)
  8239.         IF x   y THEN z = "3" ELSE "4"     (The "equals" comparator is omitted)
  8240.         IF x = y THEN z = "3" ELSE "4"     (This is a lot easier to read)
  8241.     
  8242.  
  8243.  
  8244.  
  8245.  
  8246.  
  8247.  
  8248.  
  8249.                                                                             141
  8250.     With some restrictions (discussed later), literal comparators work on
  8251.     numeric and alphabetic data.  Here are some examples of literal comparisons
  8252.     that are "true":
  8253.     
  8254.                    "ABC" <>      "ABCD"      "3" <>      "4"
  8255.                    "ABC" <=      "ABCD"      "3" <=      "4"
  8256.                    "ABC" <       "ABCD"      "3" <       "4"
  8257.                    "ABC" SHORTER "ABCD"      "3" SAMELEN "4"
  8258.     
  8259.                    "ABC" >=      "ABC"       "ABC" <>      "CDE"
  8260.                    "ABC" <=      "ABC"       "ABC" <=      "CDE"
  8261.                    "ABC" =       "ABC"       "ABC" <       "CDE"
  8262.                    "ABC" ^       "ABC"       "ABC" SAMELEN "CDE"
  8263.                    "ABC" SAMELEN "ABC"       "ABC" ~       "CDE"
  8264.     
  8265.     ----------------------------------
  8266.     Literal Comparisons and Sort Order
  8267.     ----------------------------------
  8268.     
  8269.     Some of the literal comparators compare text according to "PC-ASCII sort
  8270.     order".  For plain English text, this works fine.  However, if your text
  8271.     contains diacritical (accented) characters, you should be aware that
  8272.     some comparisons will not work correctly.  For example, the "A-Umlaut"
  8273.     character appears in the PC-ASCII character set AFTER the PC-ASCII value
  8274.     for "Z".
  8275.     
  8276.     -------------------
  8277.     Numeric Comparisons
  8278.     -------------------
  8279.     
  8280.     Some confusion can arise if you use literal comparators on numbers.  For
  8281.     example, this doesn't work as you might expect at first glance:
  8282.     
  8283.     SET count = count+
  8284.     BEGIN count >= "2"
  8285.       OUTEND x = x |{count}
  8286.     END
  8287.     
  8288.     You might expect this POM file to output any number greater than or equal
  8289.     to "2", but in fact, you will get a different result, because the
  8290.     comparison is a literal (text) comparison.  In the example above, "2" to
  8291.     "9" are greater or equal to "2", but "10" (which starts with "1") is less,
  8292.     as is evident when you sort several numbers alphabetically:
  8293.     
  8294.  
  8295.  
  8296.  
  8297.  
  8298.  
  8299.  
  8300.  
  8301.  
  8302.  
  8303.  
  8304.                                                                             142
  8305.     1
  8306.     10
  8307.     11
  8308.     15
  8309.     100
  8310.     2
  8311.     20
  8312.     200
  8313.     3
  8314.     30
  8315.     
  8316.     As you can see, the values 1, 10, 11 and 15 come before "2" when sorted
  8317.     alphabetically.
  8318.     
  8319.     To compare numbers, you should use the numeric comparators.  The correct
  8320.     way to code the previous example is as follows:
  8321.     
  8322.     SET count = count+
  8323.     BEGIN Count #>= "2"           <-- Note the #>= comparator
  8324.       OUTEND x = x |{count}
  8325.     END
  8326.     
  8327.     Written in this way, numbers greater than or equal to two will be output.
  8328.     
  8329.     Here are some examples of numeric comparisons that are "true":
  8330.     
  8331.                     "345" #<>  "567"         "1.23" #<>  "9.87"
  8332.     
  8333.                     "345" #<=  "567"         "1.23" #<=  "9.87"
  8334.     
  8335.                     "567" #>   "345"         "9.87" #>   "1.23"
  8336.     
  8337.                     "3"   #<   "6.2"
  8338.     
  8339.     The last example compares an integer ("3") with a real number ("6.2"). The
  8340.     numeric comparators automatically check if one of the numbers contains a
  8341.     decimal point.  In such case, the comparison is performed in "real number"
  8342.     mode, which imposes the accuracy restrictions described in the section "The
  8343.     CalcReal Command".  This might create a problem if you are comparing a
  8344.     decimal number with a large integer, but this is not a cause for much
  8345.     worry, since most parsing jobs tend to compare similar types of numbers.
  8346.     
  8347.     -------------------------------
  8348.     Upgrading from Earlier Versions
  8349.     -------------------------------
  8350.     
  8351.     IF YOU USED PARSE-O-MATIC PRIOR TO VERSION 3.00:  Because the comparator
  8352.     defaults to "literally identical" if it is omitted, POM files created
  8353.     before version 3.00 will continue to function normally -- with two notable
  8354.     exceptions. In older versions, the IGNORE and ACCEPT commands defaulted to
  8355.     "contains". If you have POM files that were created for older versions, you
  8356.     should check your IGNORE and ACCEPT commands to ensure that they are doing
  8357.     what you want them to.
  8358.  
  8359.                                                                             143
  8360.                                ---------------------
  8361.                                Predefined Data Types
  8362.                                ---------------------
  8363.     
  8364.     For certain commands (e.g. MAKEDATA, MAKETEXT, GET and GETTEXT),
  8365.     Parse-O-Matic has internal definitions of certain data representations;
  8366.     these are known as Parse-O-Matic's "predefined data types":
  8367.     
  8368.            DATA TYPE  BYTES  MINIMUM VALUE MAXIMUM VALUE  COMMENTS
  8369.            ---------  -----  ------------- -------------  -----------
  8370.            BYTE         1                0           255
  8371.            INTEGER      2           -32768         32767
  8372.            LONGINT      4      -2147483648    2147483647
  8373.            REAL         6    -9999999999.9  9999999999.9  See NOTE #1
  8374.            SHORTINT     1             -128           127
  8375.            WORD         2                0         65535
  8376.            DATE         -                -             -  See NOTE #2
  8377.            TRIMMED      -          0 chars     255 chars  See NOTE #3
  8378.     
  8379.     NOTE #1:  The minimum and maximum values depend on the number of digits of
  8380.               precision.  See "The CalcReal Command" for details.
  8381.     
  8382.     NOTE #2:  The DATE type does not have a specific length.  In some input
  8383.               files, a date serial number might be represented by a numeric
  8384.               format such as INTEGER or LONGINT.  For more information, see
  8385.               the discussions of the MAKETEXT, MAKEDATA and GETTEXT commands.
  8386.     
  8387.     NOTE #3:  The TRIMMED type does not have a specific length.  You can use
  8388.               it with MAKETEXT and GETTEXT commands to remove the spaces, tabs
  8389.               and nulls on either side of a string.  It can also be used with
  8390.               MAKEDATA, but since this can produce a field of indeterminate
  8391.               length, it is rarely useful in such a role.
  8392.     
  8393.     Certain predefined data types can have a qualifier, which provides
  8394.     additional information.  All commands that use predefined data types will
  8395.     accept the qualifier, but only the MAKETEXT command makes use of it.
  8396.     
  8397.     DATA TYPE  QUALIFIER DESCRIPTION     EXAMPLES
  8398.     ---------  ------------------------  -------------------------------------
  8399.     REAL       Number of decimal places  "REAL 2" -> 3.14  "REAL 4" -> 3.1415
  8400.     DATE       Date format               "DATE ?y/?n/?d" -> "96/12/01"
  8401.     
  8402.  
  8403.  
  8404.  
  8405.  
  8406.  
  8407.  
  8408.  
  8409.  
  8410.  
  8411.  
  8412.  
  8413.  
  8414.                                                                             144
  8415.     -----------------------------------
  8416.     Interpreting Data Formats in a File
  8417.     -----------------------------------
  8418.     
  8419.     When inspecting a hex dump of a binary file, bear in mind that on
  8420.     PC-compatible computers, the bytes that comprise a number are often
  8421.     reversed.  For example, for the INTEGER and WORD data types, the eight most
  8422.     significant bits of numeric values are usually placed AFTER the eight least
  8423.     significant bits.  Thus, the decimal value 5099 will appear as EB 13 in the
  8424.     file, not 13 EB, despite the fact that decimal 5099 equals hex 13EB.
  8425.     
  8426.     If you are dealing with data that treats numbers differently, you can
  8427.     sometimes work around the problem by reversing the order of the bytes
  8428.     before performing the conversion.  For example, if the file contains a WORD
  8429.     data type, but has the most significant byte FIRST, you can switch things
  8430.     around, as demonstrated by this POM file:
  8431.     
  8432.     CHOP     0                      <-- Read the file manually
  8433.     GET      x "WORD"               <-- Get two bytes from the file
  8434.     APPEND   y = x[2] x[1]          <-- Flip the bytes around
  8435.     MAKETEXT z y "WORD"             <-- Convert the number
  8436.     OUTEND   |{z}                   <-- Output the result
  8437.     
  8438.     
  8439.     
  8440.  
  8441.  
  8442.  
  8443.  
  8444.  
  8445.  
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452.  
  8453.  
  8454.  
  8455.  
  8456.  
  8457.  
  8458.  
  8459.  
  8460.  
  8461.  
  8462.  
  8463.  
  8464.  
  8465.  
  8466.  
  8467.  
  8468.  
  8469.                                                                             145
  8470.     ============================================================================
  8471.                                  DEDUCED VARIABLES
  8472.     ============================================================================
  8473.     
  8474.                                  -----------------
  8475.                                  Deduced Variables
  8476.                                  -----------------
  8477.     
  8478.     ----------
  8479.     Definition
  8480.     ----------
  8481.     
  8482.     "Deduced Variable Names" (generally referred to as "Deduced Variables")
  8483.     provide you with powerful means for organizing and processing data.  This
  8484.     particular approach to handling variable data is not available in most
  8485.     high-level languages (e.g. C, Pascal, Basic) but is extremely helpful for a
  8486.     content-oriented language such as Parse-O-Matic.
  8487.     
  8488.     A deduced variable is a variable for which the actual name is not known when
  8489.     the program is being written.  The name itself is deduced when the actual
  8490.     POM line is run.  It is almost as if you could write a line like this:
  8491.     
  8492.     SET whatever-variable-I-should-be-using-now = "3"
  8493.     
  8494.     There are several rules by which the name is deduced.  By creating similar
  8495.     circumstances later on in the program, you can deduce the same variable name
  8496.     in another spot.
  8497.     
  8498.     Deduced variables are always surrounded by parentheses.  Here are some
  8499.     sample deduced variable names:
  8500.     
  8501.     SAMPLE      PARTS*  DEDUCTIONS  EQUIVALENT VARIABLE NAME
  8502.     ----------  ------  ----------  ------------------------
  8503.     (X)           1       None      X
  8504.     (X,Y)         2       None      X,Y
  8505.     (X,Y,Z)       3       None      X,Y,Z
  8506.     (X,@Y)        2         1       X,something
  8507.     (X,@Y,@Z)     3         2       X,something,something
  8508.     (@X,YYY,@Z)   3         2       something,YYY,something
  8509.     
  8510.     (*) A deduced variable has a maximum of three parts.
  8511.     
  8512.     As you can see:
  8513.     
  8514.     - When part of the deduced variable is NOT preceded by the "@" character,
  8515.       it is taken "as-is".
  8516.     
  8517.     - When part of the deduced variable **IS** preceded by the "@" character,
  8518.       it must be looked up.
  8519.     
  8520.  
  8521.  
  8522.  
  8523.  
  8524.                                                                             146
  8525.     -------------------
  8526.     The Look-Up Process
  8527.     -------------------
  8528.     
  8529.     The look-up process is simple:  Parse-O-Matic looks up the variable following
  8530.     the "@" character and inserts it into the deduced variable name.  For example:
  8531.     
  8532.     SET     Y = "BBB"
  8533.     SET     Z = "CCC"
  8534.     SET     (AAA,@Y,@Z) = "Quick Brown Fox"
  8535.     SET     line = (AAA,BBB,CCC)
  8536.     OUTEND  |{line}
  8537.     
  8538.     ------------
  8539.     Restrictions
  8540.     ------------
  8541.     
  8542.     There are certain limitations that affect the use of deduced variables.
  8543.     
  8544.     - You can not use them in the output picture of an OUT or OUTEND command.
  8545.       For example, the following line will result in an error:
  8546.     
  8547.       OUTEND  |We have {(PRODSTOCK,@PRODNUM} {(PRODNAMES,@PRODNUM)} in stock.
  8548.     
  8549.       The correct way to do this is as follows:
  8550.     
  8551.       SET     prodstock = (PRODSTOCK,@PRODNUM)
  8552.       SET     prodname  = (PRODNAMES,@PRODNUM)
  8553.       OUTEND  |We have {prodstock} {prodname} in stock.
  8554.     
  8555.     - The length of the deduced variable name can not exceed 12 characters.
  8556.       The following lines will result in an error:
  8557.     
  8558.       SET Part2 = "YYYYYYYYYY"
  8559.       SET Part3 = "ZZZZZZZZZZ"
  8560.       SET (XX,@Part2,@Part3) = "99"
  8561.     
  8562.       This causes an error because Parse-O-Matic tries to create a variable
  8563.       named XX,YYYYYYYYYY,ZZZZZZZZZZ -- which is 24 characters long (including
  8564.       the commas).  The maximum length for a Parse-O-Matic variable (of any
  8565.       kind) is 12 characters.  The following lines WOULD work:
  8566.     
  8567.       SET Part2 = "YYYY"
  8568.       SET Part3 = "ZZZZ"
  8569.       SET (XX,@Part2,@Part3) = "99"
  8570.     
  8571.       This would set the variable XX,YYYY,ZZZZ (which is 12 characters long,
  8572.       counting the commas) to "99".
  8573.     
  8574.  
  8575.  
  8576.  
  8577.  
  8578.  
  8579.                                                                             147
  8580.     - Deduced variables can not be used for variable CALL commands.  The
  8581.       following line would not work:
  8582.     
  8583.       CALL (ROUTINE,@RTYPE)
  8584.     
  8585.       You would have to do this as follows:
  8586.     
  8587.       SET  CallTemp = (ROUTINE,@RTYPE)
  8588.       CALL CallTemp
  8589.     
  8590.     ----------------
  8591.     Usage Guidelines
  8592.     ----------------
  8593.     
  8594.     If you know the precise name of the deduced variable you are setting, you
  8595.     can specify it directly, without the parentheses.  Thus, the following
  8596.     two commands are the same:
  8597.     
  8598.       SET (CUST,NAME,1) = "Fred Jones"
  8599.       SET  CUST,NAME,1  = "Fred Jones"
  8600.     
  8601.     In other words, if a deduced variable name does not include a look-up (i.e.
  8602.     the "@" character), it is not actually being deduced.
  8603.     
  8604.     If you use substrings with deduced variables, you must specify the indexes
  8605.     immediately after the closing parenthesis.  Thus:
  8606.     
  8607.       (Data,@Y,@Z)[10 80]               <-- This is okay
  8608.       (Data,@Y,@Z)  [10 80]             <-- This is wrong
  8609.       ( Data, @Y, @Z )[ 10 80 ]         <-- This is okay
  8610.     
  8611.     The third example shows that you can use spaces within the parentheses and
  8612.     the brackets to improve readability.
  8613.     
  8614.     Variables are "persistent" (see "Uninitialized and Persistent Variables").
  8615.     This can be a problem if you are creating variables (particularly arrays)
  8616.     while processing multiple input files:  all variables created for the
  8617.     previous input file are still around.  For this reason, you may find it
  8618.     necessary to create an initializing section (in the PROLOGUE) which ensures
  8619.     that all working variables are "set to zero", so to speak.
  8620.     
  8621.  
  8622.  
  8623.  
  8624.  
  8625.  
  8626.  
  8627.  
  8628.  
  8629.  
  8630.  
  8631.  
  8632.  
  8633.  
  8634.                                                                             148
  8635.                                   ---------------
  8636.                                   Array Variables
  8637.                                   ---------------
  8638.     
  8639.                    NOTE:  For background information, please see
  8640.                           "Deduced Variables - Definition".
  8641.     
  8642.     Array variables are deduced variables that use something distinctive about
  8643.     each input item (e.g. a product number) to allow data for similar input
  8644.     items to be treated in the same way.  Here is an example of array handling:
  8645.     
  8646.     -------------------------
  8647.     Example:  Product Numbers
  8648.     -------------------------
  8649.     
  8650.     A common requirement in data processing is to assign a number to items that
  8651.     are different instances of the same thing.  For example, let's say your
  8652.     input file contained a summary of the number of items sold at your store at
  8653.     various times of the day.  You could assign a "Product Number" to each item,
  8654.     as in the following four-line input file:
  8655.     
  8656.     10:33 AM  101  Oranges    15
  8657.     11:04 AM  102  Lemons      4
  8658.     03:15 PM  104  Bananas    20
  8659.     04:41 PM  102  Lemons     25
  8660.     :         :    :          :
  8661.     :         :    :          :
  8662.     Time   Product Product    Quanity
  8663.     Sold   Code    Name       Sold
  8664.     
  8665.     You could add up the total sales for each item, as follows:
  8666.     
  8667.     SET  ProdCode = $FLINE[11 13]
  8668.     SET  Quantity = $FLINE[27 28]
  8669.     SET  (Name,@ProdCode) = $FLINE[16 22]
  8670.     CALC (Sold,@ProdCode) = (Sold,@ProdCode) "+" Quantity
  8671.     
  8672.     The first three lines obtain the product code (e.g. 101 for Oranges), the
  8673.     quantity sold, and the product name.  The fourth line adds the quantity sold
  8674.     to the appropriate product.  Thus, after all four input lines have been
  8675.     processed, you will have created six deduced variables:
  8676.     
  8677.     VARIABLE         VALUE
  8678.     ---------------  -----
  8679.     Name,101         "Oranges"
  8680.     Name,102         "Lemons "
  8681.     Name,104         "Bananas"
  8682.     Sold,101         "15"
  8683.     Sold,102         "29"         <-- "29" is the total of 2nd and 4th input lines
  8684.     Sold,104         "20"
  8685.     
  8686.     There are no variables created for product numbers that did not appear in
  8687.     the input file, so if (for example) you test the value of Sold,103 it will
  8688.  
  8689.                                                                             149
  8690.     be reported as a null (empty) value.  That is because it was never assigned
  8691.     a value.
  8692.     
  8693.     Now that you have added up the totals, you can output them in the EPILOGUE
  8694.     section of the POM file.  (The EPILOGUE is the last section of POM code run,
  8695.     after all the input lines have been read.)
  8696.     
  8697.     EPILOGUE
  8698.       SET   MaxProdCode = "104"
  8699.       SET   ProdCode = "100"
  8700.       BEGIN
  8701.         IF     (Sold,@ProdCode) <> "" THEN NumSold = (Sold,@ProdCode) ELSE "NONE"
  8702.         PAD    (Name,@ProdCode) "R" " " "7"
  8703.         SET    ProdName = (Name,@ProdCode)
  8704.         OUTEND |Product # {ProdCode} ({ProdName}):  Sold {NumSold}
  8705.         SET    ProdCode = ProdCode+
  8706.       AGAIN ProdCode #<= MaxProdCode
  8707.     END
  8708.     
  8709.     The output from the POM file will look like this:
  8710.     
  8711.     Product # 100 (       ): Sold NONE
  8712.     Product # 101 (Oranges): Sold 15
  8713.     Product # 102 (Lemons ): Sold 29
  8714.     Product # 103 (       ): Sold NONE
  8715.     Product # 104 (Bananas): Sold 20
  8716.     
  8717.     There is no data for products 100 and 103, since they did not appear in the
  8718.     input file, so they do not show any data in the output.
  8719.     
  8720.     -----------------------
  8721.     Multidimensional Arrays
  8722.     -----------------------
  8723.     
  8724.     The example given above used "two dimensional arrays", which is to say that
  8725.     each array has two parts (e.g. Sold,101 has the parts Sold and 101).  Since
  8726.     deduced variables can have up to three parts, you can create arrays of up to
  8727.     three dimensions.
  8728.     
  8729.  
  8730.  
  8731.  
  8732.  
  8733.  
  8734.  
  8735.  
  8736.  
  8737.  
  8738.  
  8739.  
  8740.  
  8741.  
  8742.  
  8743.  
  8744.                                                                             150
  8745.                                 -------------------
  8746.                                 Eponymous Variables
  8747.                                 -------------------
  8748.     
  8749.                    NOTE:  For background information, please see
  8750.                           "Deduced Variables - Definition".
  8751.     
  8752.     Sometimes you do not have a convenient number (such as a product number) to
  8753.     organize your arrays.  In such cases, you can use the input item itself as
  8754.     the name of the variable.  This technique is known as "eponymous variables".
  8755.     (Eponymous means "self-naming".)
  8756.     
  8757.     Let us say your store sells only two items -- dogs and cats -- and you do
  8758.     not have a product number for each.   Your input file may look like this:
  8759.     
  8760.     10:00  Cat    1
  8761.     10:30  Dog    2
  8762.     11:00  Cat   10
  8763.     11:30  Cat    1
  8764.     12:00  Dog    1
  8765.     
  8766.     You can add up the items with the following POM file:
  8767.     
  8768.     SET   type  = $FLINE[ 8 10]
  8769.     SET   quant = $FLINE[14 15]
  8770.     CALC  (@type) = (@type) "+" quant
  8771.     
  8772.     After all of the input lines are read, you will have created two eponymous
  8773.     variables, as follows:
  8774.     
  8775.     VARIABLE         VALUE
  8776.     ---------------  -----
  8777.     Cat              "12"     <-- Total of input lines 1, 3 and 4
  8778.     Dog              "3"      <-- Total of input lines 2 and 5
  8779.     
  8780.     The totals can then be output in the EPILOGUE, using the following POM code:
  8781.     
  8782.     EPILOGUE
  8783.       OUTEND |Cats sold:  {Cat}
  8784.       OUTEND |Dogs sold:  {Dog}
  8785.     END
  8786.     
  8787.     If you decide to add cows to your product line-up, you need only add a
  8788.     single line to your EPILOGUE:
  8789.     
  8790.       OUTEND |Cows sold:  {Cow}
  8791.     
  8792.     Eponymous techniques can be more complicated than the example shown.  For
  8793.     example, you could create sub-categories such as Dog,Beagle,Large.
  8794.     
  8795.  
  8796.  
  8797.  
  8798.  
  8799.                                                                             151
  8800.     ------------------------
  8801.     Drawbacks and Advantages
  8802.     ------------------------
  8803.     
  8804.     The main drawback of eponymous variables is that the POM file must "know"
  8805.     all the possible variable names in order to output them.  If you have a
  8806.     small number of items (e.g. Cat, Dog, Cow) this is not a serious problem.
  8807.     If you DO have a large number of items, you can build an array -- "on the
  8808.     fly" as it were -- that adds each new eponymous variable name as it is
  8809.     created. You could then loop through this array, during output, to obtain
  8810.     the names.
  8811.     
  8812.     This may sound complex, but it is enormously powerful.  It means that you
  8813.     can create a parsing application that can handle input files containing
  8814.     items whose names are unknown to you.  A properly constructed POM file would
  8815.     handle new items without any modifications to the POM code.
  8816.     
  8817.     
  8818.     
  8819.  
  8820.  
  8821.  
  8822.  
  8823.  
  8824.  
  8825.  
  8826.  
  8827.  
  8828.  
  8829.  
  8830.  
  8831.  
  8832.  
  8833.  
  8834.  
  8835.  
  8836.  
  8837.  
  8838.  
  8839.  
  8840.  
  8841.  
  8842.  
  8843.  
  8844.  
  8845.  
  8846.  
  8847.  
  8848.  
  8849.  
  8850.  
  8851.  
  8852.  
  8853.  
  8854.                                                                             152
  8855.     ============================================================================
  8856.                                   VALUE TECHNIQUES
  8857.     ============================================================================
  8858.     
  8859.                 This section describes useful techniques you can use
  8860.                      when dealing with variables and literals.
  8861.     
  8862.                        --------------------------------------
  8863.                        Uninitialized and Persistent Variables
  8864.                        --------------------------------------
  8865.     
  8866.     Even before a variable is assigned a value (using the SET command, for
  8867.     example), you can use it in a POM command.  An uninitialized variable has a
  8868.     null value ("") and is treated normally by all commands.
  8869.     
  8870.     EXCEPTION:  To help you catch coding errors, the OUT and OUTEND commands
  8871.     do not allow you to output an uninitialized variable.  If you attempt to
  8872.     do so, Parse-O-Matic issues a warning, and processing is terminated.
  8873.     
  8874.     Variables are "persistent":  once you have assigned a value to a variable,
  8875.     it retains that value until it is changed.  Even if you open a new input
  8876.     file (see "POM and Wildcards") or a new output file (see "The OFile
  8877.     Command"), all variables will retain their values; they will not be "reset"
  8878.     back to null.  (Of course, when Parse-O-Matic ends, all variables
  8879.     disappear; they are not retained between separate runs of POM.)
  8880.     
  8881.     -------
  8882.     Example
  8883.     -------
  8884.     
  8885.     Here is an example which illustrates why persistent variables are useful:
  8886.     
  8887.     PAGELEN "55"                       <-- Set page length
  8888.     SET partnum = $FLINE[ 1 10]        <-- Extract the part number
  8889.     SET descrip = $FLINE[12 60]        <-- Extract the description
  8890.     BEGIN lastpart <> partnum          <-- Is this a new part number?
  8891.       OUTPAGE                          <-- Generate a page eject
  8892.       OUTHDG |PartNumber Description   <-- Output a heading
  8893.       OUTHDG |---------- -----------   <-- Output a heading
  8894.       SET    lastpart = partnum        <-- Remember the current part number
  8895.     END                                <-- End of BEGIN block
  8896.     OUTEND |{partnum} {descrip}        <-- Output the part number
  8897.     
  8898.     The first time a line is read from the input file, the lastpart variable
  8899.     will be null ("") because it has not yet been initialized.  As a result,
  8900.     the BEGIN block will be executed.  (The OUTPAGE command will be ignored
  8901.     in this first instance, since no data has been sent to the output file.)
  8902.     The BEGIN block also sets the lastpart variable, which will retain that
  8903.     value until it is changed.
  8904.     
  8905.     When the second input line is read (and the POM code is run again from the
  8906.     top), the BEGIN block will be run only if the current part number is
  8907.     different from the previous one (which we saved in the lastpart variable).
  8908.  
  8909.                                                                             153
  8910.     However, if the partnum variable is different, the BEGIN block will be run,
  8911.     outputting the page eject and headings, and once again saving the partnum
  8912.     in the lastpart variable, so we can check it during the third input line --
  8913.     and so on.
  8914.     
  8915.                         ------------------------------------
  8916.                         Inline Incrementing and Decrementing
  8917.                         ------------------------------------
  8918.     
  8919.     You can add "1" to a variable in a command.  For example:
  8920.     
  8921.     SET x = "3"
  8922.     SET x = x+
  8923.     
  8924.     After the second statement, x would have the value "4".  Here are some
  8925.     additional examples:
  8926.     
  8927.     - Incrementing "1" gives you "2"
  8928.     - Incrementing "9" gives you "10"
  8929.     - Incrementing "99" gives you "100"
  8930.     
  8931.     The first time a variable is referenced, it has a null value (unless you
  8932.     SET it yourself).  If you increment a null variable, it will be changed
  8933.     from "" (i.e. null) to "1".
  8934.     
  8935.     You can also subtract "1" from a variable in a command:
  8936.     
  8937.     SET x = "3"
  8938.     SET x = x-
  8939.     
  8940.     After the second statement, x would have the value "2".  Here are some
  8941.     additional examples:
  8942.     
  8943.     - Decrementing "0" gives you "-1"
  8944.     - Decrementing "1" gives you "0"
  8945.     - Decrementing "99" gives you "98"
  8946.     
  8947.     When you do an inline increment or decrement, the variable itself is not
  8948.     changed.  (C programmers take note!)  For example:
  8949.     
  8950.     SET y = "3"
  8951.     SET x = y-
  8952.     
  8953.     After the second line, the x variable will equal "2", while the y variable
  8954.     will still equal "3".
  8955.     
  8956.     You can use inline incrementing or decrementing with substrings:
  8957.     
  8958.     SET y = "X23X"
  8959.     SET x = y[2 3]+
  8960.     
  8961.     After the second line, the x variable will equal "24", while the y variable
  8962.     will still equal "X23X".
  8963.  
  8964.                                                                             154
  8965.     Only integer numeric values can be incremented or decremented.  If you
  8966.     attempt to increment or decrement another type of variable (e.g. text or a
  8967.     decimal number), Parse-O-Matic will halt, and report an error.
  8968.     
  8969.                                    -------------
  8970.                                    Line Counters
  8971.                                    -------------
  8972.     
  8973.     If your input record is divided over several lines (due to its original
  8974.     format or perhaps because you used the SPLIT or CHOP command), it is
  8975.     helpful to set up a line counter.  The following example extracts the first
  8976.     six characters of the second line of input records that span three lines
  8977.     (designated lines 0, 1 & 2):
  8978.     
  8979.     IF     LineCntr = "1" THEN MyField = $FLINE[1 6]
  8980.     OUTEND LineCntr = "1" |{MyField}
  8981.     IF     LineCntr = "2" THEN LineCntr = "" ELSE LineCntr+
  8982.     
  8983.     For an alternative to line counters, see "The ReadNext Command".
  8984.     
  8985.                                 -------------------
  8986.                                 The SHOWNUM Utility
  8987.                                 -------------------
  8988.     
  8989.     The ShowNum program (SHOWNUM.EXE in the standard Parse-O-Matic package) is a
  8990.     small utility which converts a hex number to decimal and vice-versa. It can
  8991.     also convert a character to its ASCII equivalent value in decimal or hex.
  8992.     
  8993.     ShowNum is helpful when you are working on a task that forces you to deal
  8994.     with data in hex or decimal form.  It is a handy tool if you are working
  8995.     with binary input or output files.
  8996.     
  8997.     You can probably find fancier conversion-reference utilities than SHOWNUM,
  8998.     but this one comes ready-to-go with Parse-O-Matic -- and it is free.  You
  8999.     may give unaltered copies of SHOWNUM to anybody without paying royalties.
  9000.     
  9001.     ----------------------
  9002.     Quick Reference Screen
  9003.     ----------------------
  9004.     
  9005.     To display a quick-reference help screen, enter the following command at
  9006.     the DOS prompt:
  9007.     
  9008.     SHOWNUM /?
  9009.     
  9010.     If you are calling SHOWNUM from Windows, you can add the /P (Pause) option
  9011.     to make it wait for a keypress before terminating:
  9012.     
  9013.     SHOWNUM /? /P
  9014.     
  9015.  
  9016.  
  9017.  
  9018.  
  9019.                                                                             155
  9020.     -------------------
  9021.     Converting a Number
  9022.     -------------------
  9023.     
  9024.     To find out what the decimal number 123 is in hexadecimal, enter the
  9025.     following command at the DOS prompt:
  9026.     
  9027.     SHOWNUM #123
  9028.     
  9029.     The # character tells ShowNum that the number is in decimal.  The program
  9030.     will display:
  9031.     
  9032.     #123 = $7B
  9033.     
  9034.     To find out what hex 400F is in decimal, enter the following command at
  9035.     the DOS prompt:
  9036.     
  9037.     SHOWNUM $400F
  9038.     
  9039.     The $ character tells ShowNum that the number is in hexadecimal.  The
  9040.     program will display:
  9041.     
  9042.     $400F = #16399
  9043.     
  9044.     ShowNum can handle numbers between -2,147,483,648 (hex $80000000) and
  9045.     2,147,483,647 (hex $7FFFFFFF).
  9046.     
  9047.     ----------------------
  9048.     Converting a Character
  9049.     ----------------------
  9050.     
  9051.     To find out a character's ASCII equivalent value in decimal and hex, use
  9052.     the SHOWNUM utility this way:
  9053.     
  9054.     SHOWNUM A
  9055.     
  9056.     This will display:
  9057.     
  9058.     A = #65 $41
  9059.     
  9060.     In other words, the letter "A" is ASCII decimal 65, which is hex 41.
  9061.     
  9062.     You can enclose the character in quotes if you wish.  This is strictly
  9063.     necessary only if you are trying to remember the values for "space":
  9064.     
  9065.     SHOWNUM " "
  9066.     
  9067.     This will display:
  9068.     
  9069.     " " = #32 $20
  9070.     
  9071.  
  9072.  
  9073.  
  9074.                                                                             156
  9075.     Character conversion works only one character at a time:
  9076.     
  9077.     SHOWNUM "ABCD"       <-- This is incorrect
  9078.     
  9079.     This would display:
  9080.     
  9081.     "ABCD" = #65 $41
  9082.     
  9083.     As you can see, only the first character ("A") is being converted.
  9084.     
  9085.     ----------------------
  9086.     Windows Considerations
  9087.     ----------------------
  9088.     
  9089.     Depending on how you call SHOWNUM from Windows, your answer may vanish when
  9090.     the program ends.  You can use the /P option to pause the program just
  9091.     before it terminates, to give yourself time to see the result.
  9092.     
  9093.     The /P option goes after the number or character parameter, as in these
  9094.     examples:
  9095.     
  9096.     SHOWNUM #123 /P
  9097.     SHOWNUM $3F2E70AE /P
  9098.     SHOWNUM A /P
  9099.     SHOWNUM "B" /P
  9100.     
  9101.     In each case the answer will be displayed, and the program will wait until
  9102.     you hit a key before terminating.
  9103.     
  9104.     You can set up a PIF file or "shortcut" (see your Windows documentation) to
  9105.     leave the window open after the program is finished, which means you do not
  9106.     have to use the /P option.  You may wish to set the PIF file to allow
  9107.     "cutting and pasting" from the program window.  This will allow you to copy
  9108.     the answer to your Windows environment -- which is easier (and more
  9109.     reliable) than writing it down then retyping it.
  9110.     
  9111.     Alternatively, you can start up a DOS shell from Windows, use SHOWNUM as
  9112.     many times as you want, then type EXIT at the DOS prompt when you are
  9113.     finished.
  9114.     
  9115.     
  9116.     
  9117.  
  9118.  
  9119.  
  9120.  
  9121.  
  9122.  
  9123.  
  9124.  
  9125.  
  9126.  
  9127.  
  9128.  
  9129.                                                                             157
  9130.     ============================================================================
  9131.                                PROGRAMMING TECHNIQUES
  9132.     ============================================================================
  9133.     
  9134.                     This section describes techniques that will
  9135.                         help you create and debug POM files.
  9136.     
  9137.                                       -------
  9138.                                       Tracing
  9139.                                       -------
  9140.     
  9141.     By setting the DOS variable POM to ALL, you can generate a trace file,
  9142.     named POM.TRC.  This is helpful if you have trouble understanding why your
  9143.     file isn't being parsed properly.  But be sure to test it with a SMALL
  9144.     input file; the trace is quite detailed, and it can easily generate a huge
  9145.     output file.
  9146.     
  9147.     To save space, you can specify a particular list of variables to be traced,
  9148.     rather than tracing everything.  For example, to trace only the variable
  9149.     PRICE, enter this DOS command:
  9150.     
  9151.     SET POM=PRICE
  9152.     
  9153.     To trace several variables, separate the variable names by slashes, as in
  9154.     this example:
  9155.     
  9156.     SET POM=PRICE/BONUS/NAME
  9157.     
  9158.     This traces the three variables PRICE, BONUS and NAME.
  9159.     
  9160.  
  9161.  
  9162.  
  9163.  
  9164.  
  9165.  
  9166.  
  9167.  
  9168.  
  9169.  
  9170.  
  9171.  
  9172.  
  9173.  
  9174.  
  9175.  
  9176.  
  9177.  
  9178.  
  9179.  
  9180.  
  9181.  
  9182.  
  9183.  
  9184.                                                                             158
  9185.                                       -------
  9186.                                       Logging
  9187.                                       -------
  9188.     
  9189.     Every time Parse-O-Matic runs, it creates a "processing log".  This is a
  9190.     text file named POMLOG.TXT, which is placed in Parse-O-Matic's home
  9191.     directory.  (For example, if POM.EXE is located in C:\POM, the file will
  9192.     be C:\POM\POMLOG.TXT even if you run POM from another directory.)  If the
  9193.     file POMLOG.TXT already exists, it is renamed to POMLOG.BAK.
  9194.     
  9195.     The processing log file POMLOG.TXT contains a report of what happened
  9196.     during the last run of Parse-O-Matic.  Usually, the file will be quite
  9197.     short and look something like this:
  9198.     
  9199.         COMMAND: POM TEST.POM TEST.TXT TEMP.TXT
  9200.         DATE:    AUG 01 1997
  9201.     
  9202.         17:50:10 TEST.TXT opened for processing
  9203.         17:50:14 TEST.TXT processing completed
  9204.     
  9205.     The first line gives the DOS command line, while the second gives the
  9206.     date.  Subsequent lines give the time (Hours:Minutes:Seconds) and a
  9207.     progress or error message.
  9208.     
  9209.     If you encounter an error during processing, the text of the warning
  9210.     message is saved in the processing log.  It might look something like this:
  9211.     
  9212.         COMMAND: POM TEST.POM TEST.TXT TEMP.TXT
  9213.         DATE:    AUG 01 1997
  9214.     
  9215.         17:50:10 TEST.TXT opened for processing
  9216.         17:50:10 Execution error in line number 3 of POM file TEST.POM
  9217.         17:50:11 Required parameter is missing in OUT
  9218.     
  9219.     If you process multiple input files, POMLOG.TXT might look something
  9220.     like this:
  9221.     
  9222.         COMMAND: POM EXAMPL15.POM DATA*.TXT TEMP.TXT
  9223.         DATE:    AUG 01 1997
  9224.     
  9225.         14:21:27 DATA01.TXT opened for processing
  9226.         14:21:28 DATA01.TXT processing completed
  9227.     
  9228.         14:21:28 DATA02.TXT opened for processing
  9229.         14:21:28 DATA02.TXT processing completed
  9230.     
  9231.         14:21:28 DATA03.TXT opened for processing
  9232.         14:21:28 DATA03.TXT processing completed
  9233.     
  9234.     If for some reason the processing log can not be created, Parse-O-Matic
  9235.     will continue to run; it will not terminate.  For some additional comments
  9236.     on logging, see "Unattended Operation".
  9237.     
  9238.  
  9239.                                                                             159
  9240.     ============================================================================
  9241.                               COMMAND-LINE TECHNIQUES
  9242.     ============================================================================
  9243.     
  9244.                      This section describe the various options
  9245.                            available at the command line.
  9246.     
  9247.                                      ----------
  9248.                                      Quiet Mode
  9249.                                      ----------
  9250.     
  9251.     Sometimes you don't want the user to see the Parse-O-Matic processing
  9252.     screen.  In such cases, you can use the "Quiet Mode" switch (/Q) on the
  9253.     command line.  For example:
  9254.     
  9255.     POM XYZ.POM MYFILE.TXT TEMP.TXT /Q
  9256.     
  9257.     The /Q switch suppresses the display of the processing screen.  The only
  9258.     time a user will see anything is if there is a problem (for example:  the
  9259.     input file was not found).  In such case, Parse-O-Matic will make a noise
  9260.     via the PC speaker, then display a message (see "Unattended Operation" and
  9261.     "The MSGWAIT Command" for some background information).
  9262.     
  9263.                        --------------------------------------
  9264.                        User-Specified Command-Line Parameters
  9265.                        --------------------------------------
  9266.     
  9267.     Some POM applications are easier to use if you can pass a value on the
  9268.     command line.  For example, let us say you have created a POM file that will
  9269.     search a text file for a particular word, and output all the lines that
  9270.     contain that word.  You could manually change the POM file each time, but
  9271.     this is not a practical solution if many people will be using the
  9272.     application.
  9273.     
  9274.     The alternative is to use user-defined command line parameters to pass the
  9275.     value.  Consider this POM file, which we will name FINDWORD.POM:
  9276.     
  9277.     ACCEPT $FLINE ^ $CMDLINEX
  9278.     OUTEND |{$FLINE}
  9279.     
  9280.     This will output any lines that contain (^) the value of $CMDLINEX.  This
  9281.     variable is set if you use the /X command line parameter.  Thus, you would
  9282.     call the POM file as follows:
  9283.     
  9284.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /Xadministration
  9285.     
  9286.     This would read the file INPUT.TXT and send any lines containing the word
  9287.     "administration" (in lowercase) to the file OUTPUT.TXT.
  9288.     
  9289.  
  9290.  
  9291.  
  9292.  
  9293.  
  9294.                                                                             160
  9295.     There are three user-specified command line parameters:
  9296.     
  9297.     PARAMETER   SETS VARIABLE
  9298.     ---------   -------------
  9299.        /X         $CMDLINEX
  9300.        /Y         $CMDLINEY
  9301.        /Z         $CMDLINEZ
  9302.     
  9303.     Like all variables, the $CMDLINEx variables can be in uppercase, lowercase
  9304.     or mixed case (e.g. $CmdLineX).
  9305.     
  9306.     Case Considerations
  9307.     -------------------
  9308.     
  9309.     The parameter letter (e.g. /X) can be in uppercase or lowercase.  The
  9310.     following two command lines are equivalent:
  9311.     
  9312.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /Xadministration
  9313.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /xadministration
  9314.     
  9315.     The value following the parameter letter is passed on "as-is"; it is not
  9316.     converted to uppercase or changed in any way.  You could modify the FINDWORD
  9317.     file (described earlier) to ignore case, as follows:
  9318.     
  9319.     CVTCASE $CMDLINEX $CMDLINEX   <-- Convert the /X value to uppercase
  9320.     ACCEPT  $FLUPC ^ $CMDLINEX    <-- Compare to the uppercase version of $FLINE
  9321.     OUTEND  |{$FLINE}             <-- Output the line if the value was found
  9322.     
  9323.     Spaces in Values
  9324.     ----------------
  9325.     
  9326.     Since command-line parameters are separated by spaces, you must enclose your
  9327.     parameter value in quotes if it contains one or more spaces.  For example:
  9328.     
  9329.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"Mr. Jones"
  9330.     
  9331.     If the parameter value contains quotes, they must be doubled-up.  Thus, if
  9332.     you were using the FINDWORD application to find
  9333.     
  9334.     The "King" of American Jazz
  9335.     
  9336.     the command would look like this:
  9337.     
  9338.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"The ""King"" of American Jazz"
  9339.     
  9340.     Command-Line Switches
  9341.     ---------------------
  9342.     
  9343.     Sometimes you want a command-line parameter to simply mean "do something".
  9344.     If it is missing from the command line, it would mean "don't do it".  You
  9345.     could specify /ZY (for "Yes, do it") and /ZN (for "No, don't do it"), but
  9346.     there is an easier way.
  9347.     
  9348.  
  9349.                                                                             161
  9350.     If a command-line parameter is missing, Parse-O-Matic sets its corresponding
  9351.     $CMDLINEx variable to "N" (meaning, "No, it's not there").  If the parameter
  9352.     is present -- with no value following it -- Parse-O-Matic sets the $CMDLINEx
  9353.     variable to "Y" (meaning "Yes, it's there").  We can use this method to
  9354.     refine the FINDWORD application described earlier...
  9355.     
  9356.     BEGIN $CMDLINEZ = "Y"
  9357.       CVTCASE $CMDLINEX $CMDLINEX
  9358.       ACCEPT  $FLUPC ^ $CMDLINEX
  9359.     ELSE
  9360.       ACCEPT  $FLINE ^ $CMDLINEX
  9361.     END
  9362.     OUTEND  |{$FLINE}
  9363.     
  9364.     In this case, the /X value (the word we are looking for) will be tested
  9365.     without regard to case (i.e. uppercase or lowercase letters) if /Z is
  9366.     present on the command line.  If /Z is missing, we will look for an exact
  9367.     match.  Here are two sample command lines:
  9368.     
  9369.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"Mr. Jones"
  9370.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X"Mr. Jones" /Z
  9371.     
  9372.     The first command would not match "Mr. Jones" with "mr. jones".  The second
  9373.     command would consider the two strings equivalent.
  9374.     
  9375.     Hex and Decimal Code Strings
  9376.     ----------------------------
  9377.     
  9378.     You can specify precise values either as a decimal ("ASCII") value, or as
  9379.     hexadecimal.  For example, the following three commands are equivalent:
  9380.     
  9381.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X" 01"
  9382.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X$20$30$31
  9383.     POM FINDWORD.POM INPUT.TXT OUTPUT.TXT /X#32#45#49
  9384.     
  9385.     All three specify the search string " 01".  The second one uses decimal
  9386.     notation for the characters, while the third one uses hexadecimal codes
  9387.     for the characters.
  9388.     
  9389.     You can not mix the decimal, hex and literal representations.  Here are
  9390.     two examples:
  9391.     
  9392.     /X#32"22"#32     is not permitted
  9393.     /X" 22 "         could be used instead
  9394.     /X#32#50#50#32   could also be used
  9395.     
  9396.     /X$30#50         is not permitted
  9397.     /X02             could be used instead
  9398.     /X"02"           could also be used
  9399.     
  9400.  
  9401.  
  9402.  
  9403.  
  9404.                                                                             162
  9405.                                       -------
  9406.                                       Summary
  9407.                                       -------
  9408.     
  9409.                SAMPLE COMMAND LINE                 VALUE OF $CMDLINEX
  9410.                ----------------------------------  ------------------
  9411.                POM A.POM B.TXT C.TXT /XHarry       Harry
  9412.                POM A.POM B.TXT C.TXT /X"The King"  The King
  9413.                POM A.POM B.TXT C.TXT /X            Y
  9414.                POM A.POM B.TXT C.TXT /XY           Y
  9415.                POM A.POM B.TXT C.TXT /XN           N
  9416.                POM A.POM B.TXT C.TXT               N
  9417.                POM A.POM B.TXT C.TXT /X$30$31      01
  9418.                POM A.POM B.TXT C.TXT /X#48#50      02
  9419.     
  9420.     
  9421.     
  9422.  
  9423.  
  9424.  
  9425.  
  9426.  
  9427.  
  9428.  
  9429.  
  9430.  
  9431.  
  9432.  
  9433.  
  9434.  
  9435.  
  9436.  
  9437.  
  9438.  
  9439.  
  9440.  
  9441.  
  9442.  
  9443.  
  9444.  
  9445.  
  9446.  
  9447.  
  9448.  
  9449.  
  9450.  
  9451.  
  9452.  
  9453.  
  9454.  
  9455.  
  9456.  
  9457.  
  9458.  
  9459.                                                                             163
  9460.     ============================================================================
  9461.                                    FILE HANDLING
  9462.     ============================================================================
  9463.     
  9464.                        -------------------------------------
  9465.                        How Parse-O-Matic Searches for a File
  9466.                        -------------------------------------
  9467.     
  9468.     When Parse-O-Matic needs to read a file, it follows this procedure:
  9469.     
  9470.     1)  Parse-O-Matic tidies up the file name in the following ways:
  9471.     
  9472.         - It removes spaces and tabs
  9473.         - It converts the file name to uppercase
  9474.         - As per DOS convention, slashes (/) are converted to backslashes (\)
  9475.         - If this type of file has a default extension, and if the file name
  9476.           does not have a period (i.e. dot) in the name, the extension is
  9477.           added.
  9478.     
  9479.     2)  If the file name is fully qualified (i.e. drive and path, or both),
  9480.         Parse-O-Matic tries to open that file.  If it can not, it terminates
  9481.         with an error message.
  9482.     
  9483.     3)  If the file name is not fully qualified, Parse-O-Matic follows this
  9484.         procedure:
  9485.     
  9486.         - It first looks for the file in the current directory.
  9487.         - If then looks in the directory where the Parse-O-Matic program
  9488.           (POM.EXE) is located.
  9489.         - It then searches the DOS PATH for the file.  (For information
  9490.           about the PATH command, refer to your operating system manual.)
  9491.         - If none of these steps locate the file, Parse-O-Matic terminates
  9492.           with an error message.
  9493.     
  9494.     The following types of files are affected...
  9495.     
  9496.     TYPE OF FILE            DEFAULT EXTENSION  REFER TO MANUAL SECTION
  9497.     ----------------------  -----------------  -----------------------
  9498.     POM (Control) File            .POM         "The POM File"
  9499.     POJ (Job) File                .POJ         "Parse-O-Matic Job (POJ) Files"
  9500.     Date Information File      See NOTE #1     "The POMDATE.CFG File"
  9501.     Lookup File                See NOTE #2     "The LookFile Command"
  9502.     Properization Exception    See NOTE #2     "The Proper Command"
  9503.     Map File                      .MPF         "The MAPFILE Command"
  9504.     
  9505.     NOTE #1:  The Date Information File is always called POMDATE.CFG.  You can
  9506.               put your standard version in the Parse-O-Matic directory. If you
  9507.               wish to override it, you should place the modified copy in your
  9508.               current (logged) directory.
  9509.     
  9510.     NOTE #2:  This type of file does not have a default extension.  However, we
  9511.               recommend "TBL" (i.e. "Table") for Lookup files and "PEF" for
  9512.               Properization Exception Files.
  9513.  
  9514.                                                                             164
  9515.     Parse-O-Matic does NOT search for input and output files.  They must be
  9516.     in the current directory, or must have a fully qualfied path.  If the
  9517.     input file is missing an extension, it is assumed to be TXT.  If the
  9518.     output file is not specified in the POM command, it is assumed to be
  9519.     Output File")
  9520.     
  9521.     Since Parse-O-Matic searches for files, you can place frequently-used
  9522.     Lookup and POM files in a directory in your DOS path.
  9523.     
  9524.                        --------------------------------------
  9525.                        How Parse-O-Matic Opens an Output File
  9526.                        --------------------------------------
  9527.     
  9528.     Parse-O-Matic opens an output file the first time one of the output
  9529.     commands (e.g. OUT, OUTEND, OUTHDG) has something to send to the file.
  9530.     When opening an output file, Parse-O-Matic follows this procedure:
  9531.     
  9532.     1)  Normally, the name of the output file is specified on the POM command
  9533.         line or (if it is omitted there), it is specified in an OFILE command
  9534.         within the POM file.
  9535.     
  9536.         If no output file name was given using either method, the name is set
  9537.         to POMOUT.TXT (in the current directory).
  9538.     
  9539.     2)  Parse-O-Matic tidies up the file name in the following ways:
  9540.     
  9541.         - It removes spaces and tabs
  9542.         - It converts the file name to uppercase
  9543.         - As per DOS convention, slashes (/) are converted to backslashes (\)
  9544.         - If the file name does not have an extension, and it does not end in
  9545.           a period or a colon, the extension TXT is added.  Thus:
  9546.     
  9547.           C:\XYZ      becomes C:\XYZ.TXT
  9548.           C:\XYZ.     stays the same
  9549.           C:\XYZ.DAT  stays the same
  9550.           LPT2:       stays the same (see "Sending Output to a Device")
  9551.     
  9552.     3)  The output file name is compared to the input file name.  If they are
  9553.         the same, Parse-O-Matic terminates with an error.  You can not send
  9554.         output to the input file, nor can you read input from the output file.
  9555.     
  9556.     4A) If the file name is preceded by a plus sign ("+"), Parse-O-Matic will
  9557.         append output to the file.  Here are some examples:
  9558.     
  9559.         +C:\XYZ.TXT   output will be appended to the file
  9560.         +LPT1:        this refers to a device, so the "+" is ignored
  9561.     
  9562.         If the file to which you are appending does not already exist, it is
  9563.         first created, as an empty file.
  9564.     
  9565.  
  9566.  
  9567.  
  9568.  
  9569.                                                                             165
  9570.     4B) If the file name is NOT preceded by a plus sign, the following
  9571.         procedure takes place:
  9572.     
  9573.         - If a file with the specified name already exists, it is renamed
  9574.           with a .BAK extension (replacing any previous file with that name).
  9575.         - The file is created, as an empty file
  9576.     
  9577.         For example, if you run Parse-O-Matic as follows:
  9578.     
  9579.         POM MYPOM.POM INPUT.TXT C:\XYZ.TXT
  9580.     
  9581.         then if C:\XYZ.TXT already exists, it is renamed to C:\XYZ.BAK.
  9582.     
  9583.     5)  Output is directed to the output file until Parse-O-Matic ends or a new
  9584.         output file name is specified by the OFILE command.
  9585.     
  9586.     REMINDER:  Parse-O-Matic does not open the output file until it is time to
  9587.     send it some data from the output commands (OUT, OUTEND etc.).  If no data
  9588.     is sent to the output file, it will contain its original data (assuming it
  9589.     already existed).  If this is a problem, you can either delete the output
  9590.     file before running Parse-O-Matic, or place the following commands in the
  9591.     PROLOGUE:
  9592.     
  9593.     ERASE "OUTPUT.TXT"      <-- Delete the output file
  9594.     OFILE "OUTPUT.TXT"      <-- Specify the output file
  9595.     
  9596.     If you do this, and no data is sent to the output file, the file will not
  9597.     exist.  You can check if POM failed by consulting the DOS ERRORLEVEL.
  9598.     (See your operating system manual for an explanation of ERRORLEVEL.)
  9599.     
  9600.     - If the ERRORLEVEL is 0 and the file does not exist, it means that POM
  9601.       ran successfully, but no output was sent to the file.
  9602.     
  9603.     - If the ERRORLEVEL is 1 or higher, and the file does not exist, it
  9604.       means that POM failed, or you used the HALT command before any output
  9605.       was sent to the file.
  9606.     
  9607.     If you are calling Parse-O-Matic from a program (rather than a batch file),
  9608.     you can check the error level using the facilities built in to the language
  9609.     in which the program was written.  For example, Turbo Pascal lets you
  9610.     run another program with the EXEC command, after which you can extract the
  9611.     ERRORLEVEL from the low byte of the DosExitCode variable.
  9612.     
  9613.  
  9614.  
  9615.  
  9616.  
  9617.  
  9618.  
  9619.  
  9620.  
  9621.  
  9622.  
  9623.  
  9624.                                                                             166
  9625.                             ---------------------------
  9626.                             Appending to an Output File
  9627.                             ---------------------------
  9628.     
  9629.     If you want to add data to the end of the output file, you have three
  9630.     alternatives:
  9631.     
  9632.     1)  Use wildcards, as explained in "POM and Wildcards".  In such case,
  9633.         the output file is empty when the first output line is generated
  9634.         (although see method #2 for an exception).  When processing with
  9635.         wildcards, all output is sent to the same file, unless you change
  9636.         the file with the OFILE command (see "The OFile Command").
  9637.     
  9638.     2)  Prefix the output file name with a plus sign.  This tells Parse-O-
  9639.         Matic that you want to add data to the end of the file, rather than
  9640.         starting with an empty file.  You can use this method on the command
  9641.         line:
  9642.     
  9643.         POM MYPOM.POM INPUT.TXT +C:\MYFILES\OUTPUT.TXT
  9644.     
  9645.         You can also use this method in the OFILE command:
  9646.     
  9647.         OFILE "+C:\MYFILES\OUTPUT.TXT"
  9648.     
  9649.         In these examples, we provided the full path name to the output file.
  9650.         If you do not specify a path name (e.g. OFILE "+OUTPUT.TXT"), the
  9651.         output file is placed in the current directory.
  9652.     
  9653.     3)  Use a batch file and the DOS COPY command to control the concatenation
  9654.         of output files.  This method is less convenient, but it allows you to
  9655.         bypass the addition of the new output if there is a processing error.
  9656.         Here is a sample batch file (comments appear after the arrows):
  9657.     
  9658.         @ECHO OFF                               <-- Turn batch echoing off
  9659.         IF EXIST OUTPUT.TXT DELETE OUTPUT.TXT   <-- Get rid of old output file
  9660.         POM MYPOM.POM INPUT.TXT OUTPUT.TXT      <-- Parse the input file
  9661.         IF ERRORLEVEL 1 GOTO QUIT               <-- Quit if there was an error
  9662.         IF NOT EXIST OUTPUT.TXT GOTO QUIT       <-- Quit if no output generated
  9663.         IF EXIST SAFETY.TXT DELETE SAFETY.TXT   <-- Get rid of old safety file
  9664.         RENAME MAINFILE.TXT SAFETY.TXT          <-- Backup the original file
  9665.         COPY SAVE.TXT+OUTPUT.TXT MAINFILE.TXT   <-- Add the new output
  9666.         :QUIT                                   <-- Batch file label for GOTO
  9667.     
  9668.         This method has the added advantage of creating a backup copy of the
  9669.         original output file.  If the data in the file is particularly
  9670.         important, you could place the file SAFETY.TXT on another hard drive.
  9671.     
  9672.  
  9673.  
  9674.  
  9675.  
  9676.  
  9677.  
  9678.  
  9679.                                                                             167
  9680.                              --------------------------
  9681.                              Sending Output to a Device
  9682.                              --------------------------
  9683.     
  9684.     Parse-O-Matic recognizes that an "output file" is actually a device if it
  9685.     has a colon (":") at the end of the name.  You can direct Parse-O-Matic's
  9686.     output to a standard device such as COM1: or LPT2: by specifying the device
  9687.     name accordingly. For example:
  9688.     
  9689.     POM XYZ.POM INPUT.TXT LPT1:
  9690.     
  9691.     This directs the output to the LPT1 printer.
  9692.     
  9693.     Parse-O-Matic can detect a "Not Ready" condition in most cases.  A printer
  9694.     is Not Ready when it is offline, out of paper, or its print buffer is full.
  9695.     
  9696.     If a Not Ready condition occurs, the following happens:
  9697.     
  9698.     - If you are running in Quiet Mode (/Q on the POM command line), a Not
  9699.       Ready condition terminates Parse-O-Matic with a DOS ERRORLEVEL of 243.
  9700.     
  9701.     - If you are not running in Quiet Mode, a message box gives you the option
  9702.       of trying again, or cancelling processing.  If you cancel, Parse-O-Matic
  9703.       terminates with a DOS ERRORLEVEL of 244.
  9704.     
  9705.     ---------
  9706.     COM Ports
  9707.     ---------
  9708.     
  9709.     If you are sending output to a COM port (e.g. COM1:) you should first set
  9710.     the baud rate with the DOS MODE command, or Pinnacle Software's MODEM
  9711.     program (available on our BBS and Web site).
  9712.     
  9713.     The MODEM program is particularly useful if your COM port is driving a
  9714.     modem.  Parse-O-Matic talks to the operating system's COM device driver
  9715.     rather than the modem itself, so before you send data to a modem, it is a
  9716.     good idea to use the MODEM program to check that the modem is online and
  9717.     functioning properly.
  9718.     
  9719.     If you are using a high-speed modem (9600 bps or higher) and you find that
  9720.     you sometimes lose some characters, the operating system or the modem may
  9721.     not be handling a "Not Ready" condition properly during handshaking.  In
  9722.     such case, you may find it necessary to turn off buffering (locked DTE
  9723.     speed) and run at a maximum speed of 9600 bps.  For a quick course in
  9724.     high-speed modems and buffering, see the Trouble-Shooting Guide included
  9725.     with Pinnacle Software's Sapphire Bulletin Board System (also available on
  9726.     our BBS and Web site).
  9727.     
  9728.     For an example of sending output to a COM port, see "The Pause Command".
  9729.     
  9730.  
  9731.  
  9732.  
  9733.  
  9734.                                                                             168
  9735.                                      ---------
  9736.                                      DbF Files
  9737.                                      ---------
  9738.     
  9739.     If Parse-O-Matic notices that the input file is a "DBase" file (i.e. it has
  9740.     a DBF extension -- for example:  MYFILE.DBF), it will change the way it
  9741.     processes the data.  For instance, the variable $FLINE is not defined.
  9742.     Rather, each of the fields in the database are pre-parsed.  Thus, if you
  9743.     have a DBF file containing three fields (EMPNUM, NAME, PHONE), your entire
  9744.     POM file might look like this:
  9745.     
  9746.     IGNORE DELETED "Y"
  9747.     OUTEND |{EMPNUM} {NAME} {PHONE}
  9748.     
  9749.     The DELETED variable is created automatically for each record.  If it is
  9750.     set to "Y", it means the record has been deleted from the database and is
  9751.     probably not valid.  In most cases, you will want to ignore such records.
  9752.     
  9753.     If you do not know what the field names are, you can obtain the list with
  9754.     the following POM file:
  9755.     
  9756.     TRACE DELETED
  9757.     
  9758.     Afterwards, when you inspect the trace file (POM.TRC), you will see a
  9759.     summary of all the fields.  Since there are no output commands (e.g. OUTEND
  9760.     and OUTHDG), the output file will be empty.
  9761.     
  9762.     NOTE:  Parse-O-Matic does not currently support DBF "Memo" fields.
  9763.     
  9764.  
  9765.  
  9766.  
  9767.  
  9768.  
  9769.  
  9770.  
  9771.  
  9772.  
  9773.  
  9774.  
  9775.  
  9776.  
  9777.  
  9778.  
  9779.  
  9780.  
  9781.  
  9782.  
  9783.  
  9784.  
  9785.  
  9786.  
  9787.  
  9788.  
  9789.                                                                             169
  9790.                                  -----------------
  9791.                                  POM and Wildcards
  9792.                                  -----------------
  9793.     
  9794.     You can process multiple input files with the same POM file by specifying a
  9795.     DOS "wildcard" at the DOS command prompt.  All output is then directed to
  9796.     the same output file.  For example:
  9797.     
  9798.     POM XYZ.POM *.TXT OUTPUT.TXT
  9799.     
  9800.     This runs XYZ POM.file on each file in the current directory with a TXT
  9801.     extension and sends all output to the file OUTPUT.TXT.
  9802.     
  9803.     The POM file can determine which file it is reading by using the predefined
  9804.     variable $COMMAND, which contains the current POM command line.
  9805.     
  9806.     Consider the following scenario:
  9807.     
  9808.     - You have installed POM.EXE in the directory path C:\UTILITY\POM
  9809.     - The current directory contains ABC.POM, MARK.TXT, MARY.TXT and JOHN.TXT
  9810.     - You enter the command POM ABC *.DAT OUT.TXT
  9811.     
  9812.     Parse-O-Matic runs ABC.POM against the three TXT files.  On the first input
  9813.     file, $COMMAND will look like this:
  9814.     
  9815.     C:\UTILITY\POM.EXE ABC.POM MARK.TXT OUT.TXT
  9816.     
  9817.     On the next two input files, it looks like this:
  9818.     
  9819.     C:\UTILITY\POM.EXE ABC.POM MARY.TXT OUT.TXT
  9820.     C:\UTILITY\POM.EXE ABC.POM JOHN.TXT OUT.TXT
  9821.     
  9822.     Note that the file OUT.TXT is NOT processed, even though it has a TXT
  9823.     extension.  POM will always avoid processing the output file.
  9824.     
  9825.     Let's say you wanted to concatenate both MARK.TXT and MARY.TXT, and put the
  9826.     file name at the top.  You could do it with this POM file, named ABC.POM:
  9827.     
  9828.     SET cmd = $COMMAND                <-- Get the command line
  9829.     BEGIN cmd <> lastcmd              <-- Has it changed?
  9830.       PARSE  fname cmd "2* " "3* "    <-- Extract the input file name
  9831.       SETLEN flen  fname              <-- Get length of input file name
  9832.       SET    uline = ""               <-- Initialize underline
  9833.       PAD    uline "L" "-" flen       <-- Set underline
  9834.       OUTEND lastcmd <> "" |          <-- Output a linefeed unless
  9835.       OUTEND lastcmd <> "" |          <-- this is the first file
  9836.       OUTEND |{fname}                 <-- Output the file name
  9837.       OUTEND |{uline}                 <-- Output the underline
  9838.       OUTEND |                        <-- Output a linefeed
  9839.       SET    lastcmd = $COMMAND       <-- Remember this command line
  9840.     END                               <-- End of code block
  9841.     OUTEND |{$FLINE}                  <-- Output a line from the input
  9842.     
  9843.  
  9844.                                                                             170
  9845.     You could then process MARK.TXT and MARY.TXT with this command line:
  9846.     
  9847.     POM ABC M*.TXT OUT.TXT
  9848.     
  9849.     This processes any file starting with an "M" that has a TXT extension.
  9850.     
  9851.     Another way to run the command is as follows:
  9852.     
  9853.     POM ABC M???.TXT OUT.TXT
  9854.     This processes any four-letter TXT file that starts with "M".
  9855.     
  9856.     For details about DOS wildcards, consult your operating system manual.
  9857.     
  9858.     
  9859.     
  9860.     
  9861.  
  9862.  
  9863.  
  9864.  
  9865.  
  9866.  
  9867.  
  9868.  
  9869.  
  9870.  
  9871.  
  9872.  
  9873.  
  9874.  
  9875.  
  9876.  
  9877.  
  9878.  
  9879.  
  9880.  
  9881.  
  9882.  
  9883.  
  9884.  
  9885.  
  9886.  
  9887.  
  9888.  
  9889.  
  9890.  
  9891.  
  9892.  
  9893.  
  9894.  
  9895.  
  9896.  
  9897.  
  9898.  
  9899.                                                                             171
  9900.     ============================================================================
  9901.                                OPERATIONAL TECHNIQUES
  9902.     ============================================================================
  9903.     
  9904.                            -----------------------------
  9905.                            Parse-O-Matic Job (POJ) Files
  9906.                            -----------------------------
  9907.     
  9908.     As explained earlier, a standard Parse-O-Matic command line looks like this:
  9909.     
  9910.     Format:   POM pom-file input-file output-file [optional parameters]
  9911.     Example:  POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  9912.     
  9913.     You can save the command specifications in a Parse-O-Matic job (.POJ) file
  9914.     so that you do not have to type them over and over again.  A POJ file is
  9915.     essentially a single-line text file that contains the specifications.
  9916.     
  9917.     ------------
  9918.     Simple Usage
  9919.     ------------
  9920.     
  9921.     Let's say you create a text file named MYJOB.POJ which contains the
  9922.     following line:
  9923.     
  9924.       POMFILE.POM REPORT.TXT OUTPUT.TXT
  9925.     
  9926.     You can then run the parsing job with the following command:
  9927.     
  9928.       POM MYJOB.POJ
  9929.     
  9930.     This would be the same as typing:
  9931.     
  9932.       POM POMFILE.POM REPORT.TXT OUTPUT.TXT
  9933.     
  9934.     NOTE:  Do NOT include the POM command in the job file.  For example:
  9935.     
  9936.       XYZ.POM ABC.TXT DEF.TXT      <-- Correct
  9937.       POM XYZ.POM ABC.TXT DEF.TXT  <-- Incorrect; the initial POM is not needed
  9938.     
  9939.     ---------------------
  9940.     Commenting a Job File
  9941.     ---------------------
  9942.     
  9943.     The POJ file can contain explanatory comments so you can document its
  9944.     purpose:  null lines and lines that start with a semi-colon are ignored.
  9945.     Thus, the MYJOB.POJ example (described above) could also have been
  9946.     written this way:
  9947.     
  9948.       ; Sample JOB file
  9949.       POMFILE.POM REPORT.TXT OUTPUT.TXT
  9950.     
  9951.     This first line is ignored, so as far as Parse-O-Matic is concerned, the
  9952.     job file contains only one line -- the command specifications.
  9953.  
  9954.                                                                             172
  9955.     (The sample PBJ files are indented here to offset them from the descriptive
  9956.     text, but a semi-colon must appear in column one to be recognized as a
  9957.     comment.)
  9958.     
  9959.     ------------------------
  9960.     Prompting for File Names
  9961.     ------------------------
  9962.     
  9963.     Job files are especially helpful when you don't know in advance which files
  9964.     will be processed, and you would like to prompt for a file name.  This lets
  9965.     you use one POM command-line to handle different situations.
  9966.     
  9967.     Let's say you create a text file named MYJOB2.POJ, which contains the
  9968.     following lines:
  9969.     
  9970.       ; Sample prompted job file
  9971.       POMFILE.POM % OUTPUT.TXT
  9972.     
  9973.     You can then run this job with the following DOS command:
  9974.     
  9975.       POM MYJOB2.POJ
  9976.     
  9977.     or simply:
  9978.     
  9979.       POM MYJOB2
  9980.     
  9981.     Since a single command-line parameter is assumed to refer to a POJ file.
  9982.     
  9983.     The % character means "Ask the user for this file".  Since, in this example,
  9984.     the % is in the second position, Parse-O-Matic will prompt you for the name
  9985.     of the input file or mask.  (If you press Esc or enter a null name,
  9986.     processing is terminated with a warning message.)
  9987.     
  9988.     Here is another example:
  9989.     
  9990.       ; Sample prompted job file
  9991.       POMFILE.POM % %
  9992.     
  9993.     This will prompt for both the input file and output file names.
  9994.     
  9995.     Now consider this example:
  9996.     
  9997.       ; Sample prompted job file
  9998.       % % %
  9999.     
  10000.     This will prompt for the POM, input and output file names -- which is not
  10001.     particularly helpful!
  10002.     
  10003.  
  10004.  
  10005.  
  10006.  
  10007.  
  10008.  
  10009.                                                                             173
  10010.     ---------------------
  10011.     Suggesting File Names
  10012.     ---------------------
  10013.     
  10014.     A % prompt will open a box on the screen to ask you for a file name (with an
  10015.     appropriate explanation of what it required) but it will not suggest a name.
  10016.     You can "feed" Parse-O-Matic a suggested name, which you can then accept by
  10017.     hitting Enter, or modify by typing a new one.
  10018.     
  10019.     To provide this default value, place the suggested file name after the %
  10020.     character.  For example:
  10021.     
  10022.       ; Sample prompted job file, with recommended file names
  10023.       POMFILE.POM %INPUT.TXT %OUTPUT.TXT
  10024.     
  10025.     When you are asked to specify the input file name, the name INPUT.TXT will
  10026.     appear in the prompt box.  It can be accepted as-is, or changed.
  10027.     
  10028.     Incidentally, if you do not provide a suggested file name for the output
  10029.     file, Parse-O-Matic will automatically suggest the name POMOUT.TXT.
  10030.     
  10031.     
  10032.     -------------------
  10033.     Optional Parameters
  10034.     -------------------
  10035.     
  10036.     You can include optional parameters in your job file line.  For example:
  10037.     
  10038.       POMFILE.POM ABC.TXT XYZ.TXT /Q
  10039.     
  10040.     Because of the /Q parameter, this will parse ABC.TXT in "Quiet mode"
  10041.     (i.e. the processing screen will not be displayed).
  10042.     
  10043.     You can not prompt for optional parameters.
  10044.     
  10045.     Because the output file name is optional in the POM command (defaulting to
  10046.     POMOUT.TXT if it is omitted, which can then be altered in the POM file
  10047.     itself with the OFILE command), it is possible to leave out the output file
  10048.     name (or prompt) in the job file:
  10049.     
  10050.       POMFILE.POM ABC.TXT /Q
  10051.     
  10052.     This assumes that the output file name is POMOUT.TXT, just as if you had
  10053.     typed the following command at the DOS prompt:
  10054.     
  10055.       POM POMFILE.POM ABC.TXT /Q
  10056.     
  10057.  
  10058.  
  10059.  
  10060.  
  10061.  
  10062.  
  10063.  
  10064.                                                                             174
  10065.     --------
  10066.     Examples
  10067.     --------
  10068.     
  10069.     The standard Parse-O-Matic package contains two sample job files, named
  10070.     SAMPJOB1.POJ and SAMPJOB2.POJ, which demonstrate simple and prompted
  10071.     usage of job files.  Both files are self-documenting, so view or print
  10072.     them out to find out how to use them.
  10073.     
  10074.                           -------------------------------
  10075.                           Encrypted (Scrambled) POM Files
  10076.                           -------------------------------
  10077.     
  10078.     Parse-O-Matic comes with a simple encryption program (named SCRAMBLE) which
  10079.     renders a POM file unreadable to humans yet still usable by Parse-O-Matic.
  10080.     
  10081.     --------------------
  10082.     The SCRAMBLE Utility
  10083.     --------------------
  10084.     
  10085.     The format of the SCRAMBLE command (entered at the DOS prompt) is as follows:
  10086.     
  10087.     SCRAMBLE filename password
  10088.     
  10089.     The filename is the name of your POM file, which will be "scrambled" into
  10090.     a seemingly meaningless jumble of characters.  The original POM file is
  10091.     renamed with a BAK extension, so if you scramble MYFILE.POM, as in this
  10092.     command:
  10093.     
  10094.     SCRAMBLE MYFILE.POM PRIVATE
  10095.     
  10096.     then two files will be created:
  10097.     
  10098.     MYFILE.POM    The scrambled POM file
  10099.     MYFILE.BAK    The original POM file
  10100.     
  10101.     The password is a code word of six letters or more that you can use to
  10102.     unscramble the file.  To do this, simply enter the SCRAMBLE command again,
  10103.     using the same password.
  10104.     
  10105.     SCRAMBLE ignores case, so the password "SECRET" is equivalent to "Secret".
  10106.     
  10107.     If the wrong password is entered, SCRAMBLE issues a warning message, pauses
  10108.     briefly, then terminates without doing anything else.
  10109.     
  10110.     For a brief summary of SCRAMBLE, enter the following command at the DOS
  10111.     prompt:
  10112.     
  10113.     SCRAMBLE /?
  10114.     
  10115.  
  10116.  
  10117.  
  10118.  
  10119.                                                                             175
  10120.     ------------------------
  10121.     Why Scramble a POM File?
  10122.     ------------------------
  10123.     
  10124.     If you are distributing a POM application, you may not want the end-users to
  10125.     be able to tamper with the POM file.  If they alter a scrambled POM file,
  10126.     they will almost certainly render it inoperable.
  10127.     
  10128.     The encryption scheme used by SCRAMBLE (and Parse-O-Matic) is not highly
  10129.     sophisticated, so there are no export restrictions on the technology.  The
  10130.     encryption could probably be "cracked" by a professional cryptologist within
  10131.     a day.  However, it should confound regular users sufficiently that they
  10132.     will not alter, excerpt or modify your POM code.
  10133.     
  10134.     When Parse-O-Matic notices that the POM file is encrypted, it disables
  10135.     tracing.  This prevents the user from using the trace facility to get a
  10136.     listing of the POM file.
  10137.     
  10138.     ----------------------
  10139.     Support Considerations
  10140.     ----------------------
  10141.     
  10142.     The SCRAMBLE program does NOT have to be present in the Parse-O-Matic
  10143.     directory for Parse-O-Matic to read scrambled files.
  10144.     
  10145.     If you are shipping a scrambled POM file to a user, you might consider
  10146.     sending along a copy of SCRAMBLE if you think the user might have to make
  10147.     some on-site changes to the POM file.  However, in order to do this, the
  10148.     user would have to know your POM file's scrambling password. In most cases
  10149.     it is probably better to provide the user with a fresh file (direct from
  10150.     you) when changes are needed.
  10151.     
  10152.     Scrambled POM files can be used with unregistered evaluation copies of
  10153.     Parse-O-Matic, although the legal requirement remains: continued use of
  10154.     Parse-O-Matic beyond 90 days requires a license (see "Licensing").  This
  10155.     lets your client try out your Parse-O-Matic solution without paying for
  10156.     Parse-O-Matic OR seeing your POM code.
  10157.     
  10158.  
  10159.  
  10160.  
  10161.  
  10162.  
  10163.  
  10164.  
  10165.  
  10166.  
  10167.  
  10168.  
  10169.  
  10170.  
  10171.  
  10172.  
  10173.  
  10174.                                                                             176
  10175.                                     -----------
  10176.                                     Batch Files
  10177.                                     -----------
  10178.     
  10179.     The built-in batch (BAT) capability of DOS and Windows is often overlooked,
  10180.     even by seasoned computer professionals.  You can use batch files to make
  10181.     Parse-O-Matic easier to use.  Batch files are created with a text editor
  10182.     (such as DOS EDIT, or Windows Notepad).
  10183.     
  10184.     --------------------------------------
  10185.     Example #1:  Save Yourself Some Typing
  10186.     --------------------------------------
  10187.     
  10188.     Here is a simple batch file (comments appear after the arrows):
  10189.     
  10190.     @ECHO OFF                               <-- Turn off command-line echoing
  10191.     POM MYPOM.POM INPUT.TXT OUTPUT.TXT      <-- Run Parse-O-Matic
  10192.     IF ERRORLEVEL 1 GOTO QUIT               <-- Quit if an error occured
  10193.     SEE OUTPUT.TXT                          <-- View the output file
  10194.     :QUIT                                   <-- Batch file label
  10195.     
  10196.     The advantage of this batch file is that it saves you the trouble of typing
  10197.     in the entire POM command line each time you want to parse the file.
  10198.     
  10199.     ----------------------------------------
  10200.     Example #2:  Streamline Your Development
  10201.     ----------------------------------------
  10202.     
  10203.     Here is a batch file which is useful during the development of a POM file.
  10204.     
  10205.     @ECHO OFF
  10206.     DEVELOP 50 MYPOM.POM IN.TXT C:\MYFILES\OUT.TXT
  10207.     
  10208.     This batch file calls DEVELOP.BAT (included with Parse-O-Matic), which
  10209.     displays a menu with the following options:
  10210.     
  10211.     INPUT ------ View input file
  10212.     EDIT ------- Edit POM file
  10213.     PARSE ------ Run parsing job
  10214.     OUTPUT ----- View output file
  10215.     QUIT ------- Finished
  10216.     
  10217.     This lets you do the parsing, view the result, make changes to the POM file
  10218.     if necessary, then parse again.  You will find that this technique makes
  10219.     development proceed quickly.
  10220.     
  10221.     Here is an explanation of the second line of the batch file:
  10222.     
  10223.  
  10224.  
  10225.  
  10226.  
  10227.  
  10228.  
  10229.                                                                             177
  10230.     DEVELOP 50 MYPOM.POM IN.TXT C:\MYFILES\OUT.TXT
  10231.     :       :  :         :      :
  10232.     :       :  :         :      :
  10233.     :       :  :         :      Name of output file  <-----
  10234.     :       :  :         :                                |
  10235.     :       :  :         Name of input file          <-------- See NOTE #1
  10236.     :       :  :                                          |
  10237.     :       :  Name of POM file                      <-----
  10238.     :       :
  10239.     :       Save position for menu                   <-------- See NOTE #2
  10240.     :
  10241.     Invokes the batch file DEVELOP.BAT
  10242.     
  10243.     NOTE #1:  You must provide the full path to the files (unless they are in
  10244.               the current directory) and the extension.
  10245.     
  10246.     NOTE #2:  The "save position" remembers where you were in the menu.  You
  10247.               may use values 49 to 99 to provide a "memory" for 50 different
  10248.               batch files that call DEVELOP.BAT.  (The other values are
  10249.               reserved for the Parse-O-Matic installation and tutorial
  10250.               procedures.)  If 50 is not enough, you can place additional
  10251.               batch files in another directory; the menu save file (POM.MSV)
  10252.               is always placed in the current directory.
  10253.     
  10254.     In order for DEVELOP.BAT to work correctly when you are in a directory
  10255.     other than the Parse-O-Matic directory, you must place the Parse-O-Matic
  10256.     directory in your DOS PATH (see your operating system manual for details).
  10257.     Your PATH must also include the directory to a text editor.  (In the
  10258.     original Parse-O-Matic package, DEVELOP.BAT calls up DOS EDIT.)
  10259.     
  10260.     You may find it instructive to study the file DEVELOP.BAT by loading it
  10261.     into a text editor.  The batch file contains some comments which explain
  10262.     how it works.  As mentioned in one of the comments, you may wish to change
  10263.     the text editor that the batch file calls for editing the POM file.
  10264.     
  10265.     You may also find the program PSMENU.EXE useful.  For a brief description,
  10266.     type PSMENU /? at the DOS prompt.  To study a typical menu definition file,
  10267.     enter the command SEE POM.MNU at the DOS prompt.
  10268.     
  10269.     ----------------------------------
  10270.     Example #3:  Automatic Batch Files
  10271.     ----------------------------------
  10272.     
  10273.     Let's say that each day you have a text file, named DELLIST.TXT, which
  10274.     lists the names of the files that need to be deleted:
  10275.     
  10276.     FRED.TXT
  10277.     MARY.TXT
  10278.     JOHN.TXT
  10279.     HARRY.TXT
  10280.     
  10281.     You could write a POM file (we'll call it MAKEDEL.POM) to write a batch
  10282.     file to delete the files.  It would look like this:
  10283.  
  10284.                                                                             178
  10285.     PROLOGUE
  10286.       OUTEND |@ECHO OFF
  10287.     END
  10288.     IGNORE $FLINE = "COMMAND.COM"           <-- An example of a safety feature!
  10289.     OUTEND $FLINE <> "" |DEL {$FLINE}
  10290.     
  10291.     You could automate the entire procedure with the following batch file
  10292.     (which we'll call DAILYDEL.BAT):
  10293.     
  10294.     @ECHO OFF                               <-- Turn off command-line echoing
  10295.     POM MAKEDEL.POM DELLIST.TXT TEMP.BAT    <-- Create the batch file TEMP.BAT
  10296.     IF ERRORLEVEL 1 GOTO QUIT               <-- Quit if an error occured
  10297.     TEMP.BAT                                <-- Run the batch file
  10298.     DEL TEMP.BAT                            <-- Delete it
  10299.     :QUIT                                   <-- Batch file label
  10300.     
  10301.     The second line of DAILYDEL.BAT runs Parse-O-Matic to create a batch file
  10302.     named TEMP.BAT.  Given the input file shown earlier, TEMP.BAT would look
  10303.     like this:
  10304.     
  10305.     @ECHO OFF
  10306.     DEL FRED.TXT
  10307.     DEL MARY.TXT
  10308.     DEL JOHN.TXT
  10309.     DEL HARRY.TXT
  10310.     
  10311.     After TEMP.BAT is created, DAILYDEL.BAT runs TEMP.BAT (thus deleting all
  10312.     the files listed in DELLIST.TXT).
  10313.     
  10314.     This is only a simple example.  Parse-O-Matic's ability to create batch
  10315.     files based on input data provides you with a very powerful tool for
  10316.     automating daily administrative tasks.
  10317.     
  10318.     When you write automatic applications, you should be careful to include
  10319.     routines in both the batch files and the POM files to handle any unusual
  10320.     conditions.  In MAKEDEL.POM, we checked the file to be sure that it wasn't
  10321.     "COMMAND.COM", because if that file is deleted, your system will probably
  10322.     stop working!
  10323.     
  10324.     ---------------------------------------------------------
  10325.     Example #4:  Controlling a POM File from the Command Line
  10326.     ---------------------------------------------------------
  10327.     
  10328.     Consider the following batch file, which we will call SELECT.BAT:
  10329.     
  10330.     @ECHO OFF                          <-- Turn off command-line echoing
  10331.     IF (%1) == () GOTO ERROR           <-- Make sure we have a parameter
  10332.     SET XYZ=%1                         <-- Set the environment variable XYZ
  10333.     POM SELECT.POM INPUT.TXT OUT.TXT   <-- Run the POM file SELECT.POM
  10334.     GOTO QUIT                          <-- Jump to the QUIT label
  10335.     :ERROR                             <-+
  10336.     ECHO Missing parameter               | Error-handling routine
  10337.     PAUSE                              <-+
  10338.  
  10339.                                                                             179
  10340.     :QUIT                              <-- Batch file label
  10341.     SET XYZ=                           <-- Get rid of the environment variable
  10342.     
  10343.     SELECT.BAT can be used with this POM file, which will we name SELECT.POM:
  10344.     
  10345.     PROLOGUE
  10346.       GETENV xyz "XYZ"
  10347.     END
  10348.     OUTEND $FLINE ^ xyz |{$FLINE}
  10349.     
  10350.     You can use SELECT.BAT to output only those lines that contain the variable
  10351.     that you specify.  For example, you can enter the following command at the
  10352.     DOS prompt:
  10353.     
  10354.     SELECT MARY
  10355.     
  10356.     This will output only those lines (from INPUT.TXT) that contain "MARY".
  10357.     If you wish to ignore distinctions between uppercase and lowercase, change
  10358.     the last line of SELECT.POM accordingly:
  10359.     
  10360.     OUTEND $FLUPC ^ xyz |{$FLINE}
  10361.     
  10362.     Batch file parameters are separated by spaces on the command line, so the
  10363.     following command would not work as you might expect:
  10364.     
  10365.     SELECT MARY FRED JOHN
  10366.     
  10367.     This would set the batch variable %1 to MARY, %2 to FRED and %3 to JOHN.
  10368.     
  10369.     One way to deal with this is to eliminate the spaces when you run the
  10370.     batch file:
  10371.     
  10372.     SELECT MARY/FRED/JOHN
  10373.     
  10374.     You can then replace the OUTEND command in SELECT.POM with these lines:
  10375.     
  10376.     APPEND x xyz "/"               <-- Set the x variable to "MARY/FRED/JOHN/"
  10377.     BEGIN x <> ""                  <-- We will loop through all of the names
  10378.       PEEL y x "" "/"              <-- Move a name to the y variable
  10379.       OUTEND $FLUPC ^ y |{$FLINE}  <-- Output a line if it contains the name
  10380.     AGAIN                          <-- Go back to the BEGIN
  10381.     
  10382.     Bear in mind that the system environment space is limited.  If you have
  10383.     problems with an application like this one, refer to "The GETENV Command",
  10384.     in the section entitled "Disappearing Environment Variables".
  10385.     
  10386.  
  10387.  
  10388.  
  10389.  
  10390.  
  10391.  
  10392.  
  10393.  
  10394.                                                                             180
  10395.                                 --------------------
  10396.                                 Unattended Operation
  10397.                                 --------------------
  10398.     
  10399.     You can design applications that run themselves while you are not there.
  10400.     There are two reasons why you might want to do this:
  10401.     
  10402.     - You can run long processing jobs just before leaving work at night
  10403.     - Parse-O-Matic is useful, but it isn't very interesting to watch!
  10404.     
  10405.     Several features of Parse-O-Matic facilitate "unattended operation".
  10406.     
  10407.     - The SOUND command can alert you if something unusual happens; you don't
  10408.       have to stare at the screen to make sure that everything is working.
  10409.     
  10410.     - All error messages (which say "Press a key to continue") make a noise
  10411.       via the PC speaker (see "The Sound Command").
  10412.     
  10413.     - You can use the MSGWAIT command to let processing continue if there is
  10414.       an error (see "The MSGWAIT Command").
  10415.     
  10416.     - The processing log (see "Logging") can be used to check processing.
  10417.     
  10418.     Let's say you wanted to concatenate (add together) several enormous text
  10419.     files.  You could start with the following POM file (named ADD.POM):
  10420.     
  10421.     SET    cmd = $COMMAND
  10422.     BEGIN  cmd <> lastcmd
  10423.       SOUND  "BEEP"
  10424.       SET     lastcmd = cmd
  10425.     END
  10426.     OUTEND |{$FLINE}
  10427.     
  10428.     You could then enter the command POM ADD.POM *.TXT ALL.TXT and walk away.
  10429.     Whenever a new file is started, you will hear a beep.  When you come back,
  10430.     you can check the file POMLOG.TXT (which will be located in the same
  10431.     directory as POM.EXE).  It might look something like this:
  10432.     
  10433.     COMMAND: POM ADD.POM *.TXT ALL.TXT
  10434.     DATE:    AUG 01 1997
  10435.     
  10436.     16:39:12 JOHN.TXT opened for processing
  10437.     16:45:28 JOHN.TXT processing completed
  10438.     
  10439.     16:45:29 MARY.TXT opened for processing
  10440.     16:52:10 MARY.TXT processing completed
  10441.     
  10442.     16:52:11 FRED.TXT opened for processing
  10443.     17:03:33 FRED.TXT processing completed
  10444.     
  10445.     If you are processing multiple files, and each one uses a different POM
  10446.     file (and hence requires a separate run of Parse-O-Matic) you can write
  10447.     your batch file so that it renames the log files.  This lets you review
  10448.  
  10449.                                                                             181
  10450.     each log file later.  For example:
  10451.     
  10452.     @ECHO OFF
  10453.     POM JOHN.POM JOHN.TXT JOHN.LST
  10454.     RENAME C:\POM\POMLOG.TXT JOHN.LOG
  10455.     POM MARY.POM MARY.TXT MARY.LST
  10456.     RENAME C:\POM\POMLOG.TXT MARY.LOG
  10457.     POM FRED.POM FRED.TXT FRED.LST
  10458.     RENAME C:\POM\POMLOG.TXT FRED.LOG
  10459.     
  10460.     When processing is complete, the files JOHN.LOG, MARY.LOG and FRED.LOG
  10461.     will be available in the directory C:\POM for your inspection.
  10462.     
  10463.     Here is a slightly more sophisticated version of the batch file:
  10464.     
  10465.     @ECHO OFF
  10466.     POM JOHN.POM JOHN.TXT JOHN.LST
  10467.     IF ERRORLEVEL 1 GOTO QUIT
  10468.     RENAME C:\POM\POMLOG.TXT JOHN.LOG
  10469.     POM MARY.POM MARY.TXT MARY.LST
  10470.     IF ERRORLEVEL 1 GOTO QUIT
  10471.     RENAME C:\POM\POMLOG.TXT MARY.LOG
  10472.     POM FRED.POM FRED.TXT FRED.LST
  10473.     IF ERRORLEVEL 1 GOTO QUIT
  10474.     RENAME C:\POM\POMLOG.TXT FRED.LOG
  10475.     :QUIT
  10476.     
  10477.     The IF ERRORLEVEL lines jump to the end of the batch file if Parse-O-Matic
  10478.     generates an error of 1 or higher.  When coding batch files, remember that
  10479.     the IF ERRORLEVEL command is considered "True" if the error is the
  10480.     specified value or higher.  This means you should always test the higher
  10481.     value first.  See your operating system manual for details.
  10482.     
  10483.  
  10484.  
  10485.  
  10486.  
  10487.  
  10488.  
  10489.  
  10490.  
  10491.  
  10492.  
  10493.  
  10494.  
  10495.  
  10496.  
  10497.  
  10498.  
  10499.  
  10500.  
  10501.  
  10502.  
  10503.  
  10504.                                                                             182
  10505.                                       --------
  10506.                                       Examples
  10507.                                       --------
  10508.     
  10509.     Many of the techniques described in this manual are demonstrated by the
  10510.     examples provided with the standard Parse-O-Matic package.  To see these
  10511.     examples, switch to your Parse-O-Matic directory, type START at the DOS
  10512.     prompt, or run START.BAT from Windows or OS/2, then select TUTORIAL.
  10513.     
  10514.     
  10515.     
  10516.  
  10517.  
  10518.  
  10519.  
  10520.  
  10521.  
  10522.  
  10523.  
  10524.  
  10525.  
  10526.  
  10527.  
  10528.  
  10529.  
  10530.  
  10531.  
  10532.  
  10533.  
  10534.  
  10535.  
  10536.  
  10537.  
  10538.  
  10539.  
  10540.  
  10541.  
  10542.  
  10543.  
  10544.  
  10545.  
  10546.  
  10547.  
  10548.  
  10549.  
  10550.  
  10551.  
  10552.  
  10553.  
  10554.  
  10555.  
  10556.  
  10557.  
  10558.  
  10559.                                                                             183
  10560.     ============================================================================
  10561.                              OPERATIONAL CONSIDERATIONS
  10562.     ============================================================================
  10563.     
  10564.                   -----------------------------------------------
  10565.                   Running Parse-O-Matic on 8088 and 8086 Machines
  10566.                   -----------------------------------------------
  10567.     
  10568.     Parse-O-Matic is designed to run on 80286 machines and higher, in "protected
  10569.     mode".  If you have a pressing need to run it on an old 8088 or 8086-class
  10570.     "real mode" machine (e.g. PC or XT), we may be able to prepare a custom copy
  10571.     for you.  Contact us for details.
  10572.     
  10573.                      ------------------------------------------
  10574.                      Running Parse-O-Matic from Another Program
  10575.                      ------------------------------------------
  10576.     
  10577.     If you are calling Parse-O-Matic from a program written in a high-level
  10578.     language (such as Pascal, Delphi, C or Basic), you can check its success or
  10579.     failure by consulting the "DOS Error Level".  Most languages have built-in
  10580.     facilities to test this value.
  10581.     
  10582.     For example, Turbo Pascal lets you run another program with the EXEC
  10583.     command, after which you can extract the ERRORLEVEL from the low byte of
  10584.     the DosExitCode variable.  You can also check the DOSERROR return code
  10585.     to check for invocation errors.  Some typical errors include:
  10586.     
  10587.     Program not found, Path not found, Access denied, Not enough memory.
  10588.     
  10589.     On long parsing jobs (taking 3 seconds or more on your slowest machine),
  10590.     it is perhaps best to let the user see the processing screen rather than
  10591.     running in Quiet Mode (see "Quiet Mode").  If nothing else, it gives him
  10592.     or her something to look at, and provides assurance that the machine has
  10593.     not stopped working.
  10594.     
  10595.  
  10596.  
  10597.  
  10598.  
  10599.  
  10600.  
  10601.  
  10602.  
  10603.  
  10604.  
  10605.  
  10606.  
  10607.  
  10608.  
  10609.  
  10610.  
  10611.  
  10612.  
  10613.  
  10614.                                                                             184
  10615.                               -----------------------
  10616.                               Solving Memory Problems
  10617.                               -----------------------
  10618.     
  10619.     Parse-O-Matic does all of its work in standard memory; it does not use
  10620.     Extended or Expanded memory.  This is rarely a problem, but if you do
  10621.     somehow run out of memory, there are some steps you can take...
  10622.     
  10623.     You can often free up some extra memory by unloading unused device drivers
  10624.     and DOS TSR ("Terminate and Stay Resident") programs.  (TSR's are sometimes
  10625.     called "DOS Pop-Ups")
  10626.     
  10627.     Alternatively, most drivers and TSR's can be safely moved into high memory,
  10628.     using the LOADHIGH function in your AUTOEXEC.BAT, or the DEVICEHIGH
  10629.     function in CONFIG.SYS.  Some older drivers and TSR's will not tolerate
  10630.     this kind of relocation.
  10631.     
  10632.     
  10633.     
  10634.  
  10635.  
  10636.  
  10637.  
  10638.  
  10639.  
  10640.  
  10641.  
  10642.  
  10643.  
  10644.  
  10645.  
  10646.  
  10647.  
  10648.  
  10649.  
  10650.  
  10651.  
  10652.  
  10653.  
  10654.  
  10655.  
  10656.  
  10657.  
  10658.  
  10659.  
  10660.  
  10661.  
  10662.  
  10663.  
  10664.  
  10665.  
  10666.  
  10667.  
  10668.  
  10669.                                                                             185
  10670.     ============================================================================
  10671.                                RUNNING UNDER WINDOWS
  10672.     ============================================================================
  10673.     
  10674.                                    -------------
  10675.                                    Compatibility
  10676.                                    -------------
  10677.     
  10678.     Parse-O-Matic is a DOS program, which has a few advantages and a few minor
  10679.     disadvantages for Windows users.
  10680.     
  10681.     The primary advantage is that a Parse-O-Matic application can run on any
  10682.     PC-compatible machine, whether it is running DOS, Windows, or OS/2.
  10683.     Emulators are also available which will let you run Parse-O-Matic (and
  10684.     other DOS software) on Macintosh computers.
  10685.     
  10686.     Since Parse-O-Matic has no user interface to speak of, Windows' wonderful
  10687.     graphical environment is not particularly important.  The only operational
  10688.     difference is that to interrupt Parse-O-Matic processing, you press the Esc
  10689.     key instead of clicking on a Cancel button.
  10690.     
  10691.     Performance is a consideration if you are running Parse-O-Matic at the same
  10692.     time as 32-bit applications under Windows 95 or NT; it will slow them down
  10693.     slightly.  However, unless you are multi-tasking heavily, performance is
  10694.     not an issue because the usual bottleneck is the responsiveness and
  10695.     transfer speed of the hard disk, not the speed at which the Parse-O-Matic
  10696.     program runs.
  10697.     
  10698.                              -------------------------
  10699.                              Setting Up for Windows 95
  10700.                              -------------------------
  10701.     
  10702.     To use Parse-O-Matic under Windows 95, you need the following items, which
  10703.     are included in the standard Parse-O-Matic package:
  10704.     
  10705.     1)  The POM file (icon file POM_FILE.ICO)
  10706.     2)  A batch file (icon file BAT.ICO)
  10707.     
  10708.     These two icon files are included in the standard Parse-O-Matic package.
  10709.     You may find it helpful to copy them to your main Windows directory so
  10710.     that the the associations you set for them are not lost if you install
  10711.     a new version of Parse-O-Matic and then delete the original POM directory.
  10712.     
  10713.  
  10714.  
  10715.  
  10716.  
  10717.  
  10718.  
  10719.  
  10720.  
  10721.  
  10722.  
  10723.  
  10724.                                                                             186
  10725.     ------------------------------------------
  10726.     Setting Up an Association for the POM File
  10727.     ------------------------------------------
  10728.     
  10729.     When you click on a POM file, it should call up a text editor.  To configure
  10730.     this, follow these steps:
  10731.     
  10732.     1)  Double-click on "My Computer"
  10733.     
  10734.     2)  From the pull-down menu, select View/Options
  10735.     
  10736.     3)  Dialog Box:  Options
  10737.         Click on the File Types tab
  10738.         Click on the New Type button
  10739.     
  10740.     4)  Dialog Box:  Add New File Type
  10741.         Description:  Parse-O-Matic Control File
  10742.         Associated extension:  POM
  10743.         Click on the New button
  10744.     
  10745.     5)  Dialog Box:  New Action
  10746.         Action:  &Edit
  10747.         Application used:  NOTEPAD.EXE (or the path to your favourite editor)
  10748.         Click on the OK button
  10749.     
  10750.     6)  Dialog Box:  Add New File Type
  10751.         Click on the Change Icon button
  10752.         Click on the Browse button
  10753.         File name: The full path to POM_FILE.ICO (e.g. C:\POM\POM_FILE.ICO)
  10754.         Press Enter
  10755.     
  10756.     7)  Dialog Box:  Change Icon
  10757.         Click the OK button
  10758.     
  10759.     8)  Dialog Box:  Add New File Type
  10760.         Click the Close button
  10761.     
  10762.     9)  Dialog Box: Options
  10763.         Click the Close button
  10764.     
  10765.     Once you have followed these steps, you can double-click on the POM file
  10766.     icon when you are in Windows Explorer or a file folder, and it will be
  10767.     opened with the file editor you specified in step 5.
  10768.     
  10769.  
  10770.  
  10771.  
  10772.  
  10773.  
  10774.  
  10775.  
  10776.  
  10777.  
  10778.  
  10779.                                                                             187
  10780.     ----------------------------------------------
  10781.     Setting Up an Association for a POJ (Job) File
  10782.     ----------------------------------------------
  10783.     
  10784.     When you click on a POJ file, it should call up Parse-O-Matic.  To configure
  10785.     this, follow these steps:
  10786.     
  10787.     1)  Double-click on "My Computer"
  10788.     
  10789.     2)  From the pull-down menu, select View/Options
  10790.     
  10791.     3)  Dialog Box:  Options
  10792.         Click on the File Types tab
  10793.         Click on the New Type button
  10794.     
  10795.     4)  Dialog Box:  Add New File Type
  10796.         Description:  Parse-O-Matic Control File
  10797.         Associated extension:  POJ
  10798.         Click on the New button
  10799.     
  10800.     5)  Dialog Box:  New Action
  10801.         Action:  &Open
  10802.         Application used:  The path to POJ_FILE.ICO (e.g. C:\POM\POJ_FILE.ICO)
  10803.         Click on the OK button
  10804.     
  10805.     6)  Dialog Box:  Add New File Type
  10806.         Click on the Change Icon button
  10807.         Click on the Browse button
  10808.         File name: The path to POJ_FILE.ICO (e.g. C:\POM\POJ_FILE.ICO)
  10809.         Press Enter
  10810.     
  10811.     7)  Dialog Box:  Change Icon
  10812.         Click the OK button
  10813.     
  10814.     8)  Dialog Box:  Add New File Type
  10815.         Click the Close button
  10816.     
  10817.     9)  Dialog Box: Options
  10818.         Click the Close button
  10819.     
  10820.     Once you have followed these steps, you can double-click on the POJ file
  10821.     icon when you are in Windows Explorer or a file folder, and it will start
  10822.     up Parse-O-Matic and run to specified job (POJ) file.
  10823.     
  10824.  
  10825.  
  10826.  
  10827.  
  10828.  
  10829.  
  10830.  
  10831.  
  10832.  
  10833.  
  10834.                                                                             188
  10835.     -----------------------------------------------------
  10836.     Setting Up an Association for the BAT File (Optional)
  10837.     -----------------------------------------------------
  10838.     
  10839.     Windows 95 is already set up to process batch (BAT) files.  However,
  10840.     Parse-O-Matic comes with an alternative icon which is more distinctive than
  10841.     the one supplied with Windows.  (The Parse-O-Matic icon looks like a bat --
  10842.     a sonar-equipped flying critter with the undeserved bad reputation).
  10843.     
  10844.     To change the icon, follow these steps:
  10845.     
  10846.     1)  Double-click on "My Computer"
  10847.     
  10848.     2)  From the pull-down menu, select View/Options
  10849.     
  10850.     3)  Dialog Box:  Options
  10851.         On the list box, find and double-click on MS-DOS Batch File
  10852.     
  10853.     4)  Dialog Box:  Edit File Type
  10854.         Click on the Change Icon button
  10855.     
  10856.     5)  Dialog Box:  Change Icon
  10857.         Click the Browse button
  10858.         File name: The full path to BAT.ICO (e.g. C:\POM\BAT.ICO)
  10859.         Press Enter
  10860.     
  10861.     6)  Dialog Box:  Change Icon
  10862.         Click the OK button
  10863.     
  10864.     7)  Dialog Box:  Edit File Type
  10865.         Click the Close button
  10866.     
  10867.     8)  Dialog Box: Options
  10868.         Click the Close button
  10869.     
  10870.     After following this procedure, your batch (BAT) file icons will be much
  10871.     more noticeable when they appear in Windows Explorer or a file folder.  To
  10872.     edit the batch file, right-click on the icon and select Edit.  To run the
  10873.     batch file, simply double-click the icon.
  10874.     
  10875.     For a discussion of batch files, see "Batch Files".
  10876.     
  10877.  
  10878.  
  10879.  
  10880.  
  10881.  
  10882.  
  10883.  
  10884.  
  10885.  
  10886.  
  10887.  
  10888.  
  10889.                                                                             189
  10890.                            ------------------------------
  10891.                            Installing the ShowNum Utility
  10892.                            ------------------------------
  10893.     
  10894.     The ShowNum program is a small utility which converts a hex number to
  10895.     decimal and vice-versa (see "The ShowNum Utility").
  10896.     
  10897.     To install ShowNum as a Windows 95 shortcut:
  10898.     
  10899.     1)  Select "File/New/Shortcut" from the pull-down menu of any folder.
  10900.     
  10901.     2)  Specify the path name to SHOWNUM.BAT, followed by a question mark.
  10902.         For example:  C:\POM\SHOWNUM.BAT ?
  10903.         The ? means "prompt for input before calling the batch file".
  10904.     
  10905.     3)  After you have finished defining the shortcut, right-click on the icon,
  10906.         select "Properties", then the "Program" tab, and make sure the "Close
  10907.         on exit" box is checked off.
  10908.     
  10909.     You can then use ShowNum by double-clicking its icon.  You will be prompted
  10910.     to enter a number, and the answer will be displayed.
  10911.     
  10912.                               ------------------------
  10913.                               Long File Names in Win95
  10914.                               ------------------------
  10915.     
  10916.     Although Parse-O-Matic can be run under Windows 95, it will only recognize
  10917.     standard DOS file names; it does not use the long file names supported by
  10918.     Win95. You can determine the underlying DOS name of a file by checking its
  10919.     "Properties" in Windows Explorer, or by using the DIR command while in DOS
  10920.     mode.
  10921.     
  10922.     
  10923.     
  10924.  
  10925.  
  10926.  
  10927.  
  10928.  
  10929.  
  10930.  
  10931.  
  10932.  
  10933.  
  10934.  
  10935.  
  10936.  
  10937.  
  10938.  
  10939.  
  10940.  
  10941.  
  10942.  
  10943.  
  10944.                                                                             190
  10945.     ============================================================================
  10946.                                      LICENSING
  10947.     ============================================================================
  10948.     
  10949.     This product is available in several forms.  For billing and pricing
  10950.     information, view or print the file ORDER.FRM.
  10951.     
  10952.                                 ----------------------
  10953.                                 Parse-O-Matic Licenses
  10954.                                 ----------------------
  10955.     
  10956.     TRIAL COPY:  If you have a "test-drive" evaluation copy, you will see a
  10957.     "Registration Reminder Screen" when you start up the program.  You are
  10958.     entitled to evaluate this program at no cost for 3 months.  If you continue
  10959.     to use it after that, you must register your copy and purchase a license,
  10960.     as described below.
  10961.     
  10962.     SINGLE-USER LICENSE:  When you register an evaluation copy of this product,
  10963.     you will receive the latest version, plus an unlocking code that will let
  10964.     you register any new evaluation versions that we release for a period of
  10965.     two years (six years for deluxe registration).
  10966.     
  10967.     SITE/MULTI-COPY LICENSES:  If you plan to run 15 or more copies of this
  10968.     program (on a network or on separate computers), you can obtain quantity
  10969.     pricing.  For details, view or print the text file ORDER.FRM.
  10970.     
  10971.     LAN LICENSE:  Local Area Network users must purchase a license for each
  10972.     user (see "Single-User License" and "Site/Multi-Copy Licenses"), although
  10973.     they can reduce this amount if they have run-control software which sets an
  10974.     upper limit on the number of concurrent users for a given program.
  10975.     
  10976.     WAN LICENSE:  Wide Area Networks are treated like LANs, but you may find it
  10977.     more economical to purchase a Distribution License (see below).
  10978.     
  10979.     DISTRIBUTION LICENSE:  The distribution license allows you to use an
  10980.     unlimited number of copies.  You may include it in your application or
  10981.     commercial package as a utility.  The only restriction is that you may not
  10982.     distribute this document (i.e. the user manual) or its essential content.
  10983.     With this safeguard, we avoid placing ourselves in competition with you;
  10984.     the program must be used to support an application or product rather than
  10985.     being its main feature.
  10986.     
  10987.     SOURCE CODE LICENSE:  If you purchase the Turbo Pascal source code, you
  10988.     must also purchase a license for each machine that will run the modified
  10989.     program.  Those portions of the source code written by Pinnacle Software
  10990.     remain copyrighted by Pinnacle, and may not be divulged to another party.
  10991.     As an alternative to purchasing the source code, you can also contract for
  10992.     us to make custom modifications to the program.
  10993.     
  10994.     RETAIL LICENSE:  You can sell complete, registered copies of this product,
  10995.     complete with documentation, in return for royalties.  The terms depend on
  10996.     volume and advance payments. Contact us for details.
  10997.     
  10998.  
  10999.                                                                             191
  11000.                                   ---------------
  11001.                                   The SEE Utility
  11002.                                   ---------------
  11003.     
  11004.     Parse-O-Matic comes with a file view/print/extract utility known as SEE
  11005.     (SEE.EXE).  The copy included in the standard package is for single-user
  11006.     operation with an evaluation or registered copy of Parse-O-Matic.  It
  11007.     may not be distributed (even if you have purchased a Distribution License
  11008.     for Parse-O-Matic).
  11009.     
  11010.     You may purchase a registered copy of SEE (including the full manual and
  11011.     walk-through).  Multi-copy and Distribution Licenses are available.  For
  11012.     more information: phone us or link up to our Web site.
  11013.  
  11014.  
  11015.  
  11016.  
  11017.  
  11018.  
  11019.  
  11020.  
  11021.  
  11022.  
  11023.  
  11024.  
  11025.  
  11026.  
  11027.  
  11028.  
  11029.  
  11030.  
  11031.  
  11032.  
  11033.  
  11034.  
  11035.  
  11036.  
  11037.  
  11038.  
  11039.  
  11040.  
  11041.  
  11042.  
  11043.  
  11044.  
  11045.  
  11046.  
  11047.  
  11048.  
  11049.  
  11050.  
  11051.  
  11052.  
  11053.  
  11054.                                                                             192
  11055.